mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Use mocked dir of web-ui for tests
This commit is contained in:
parent
21780fa2ed
commit
7d75b6248d
@ -17,10 +17,11 @@
|
||||
|
||||
import os
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from gns3server.version import __version__
|
||||
from gns3server.controller import Controller
|
||||
from gns3server.utils.static import get_static_path
|
||||
from gns3server.utils import static
|
||||
|
||||
|
||||
def test_index(http_root):
|
||||
@ -50,12 +51,14 @@ def test_project(http_root, async_run):
|
||||
|
||||
|
||||
def test_web_ui(http_root, tmpdir):
|
||||
tmpfile = get_static_path('web-ui/testing.txt')
|
||||
with open(tmpfile, 'w+') as f:
|
||||
f.write('world')
|
||||
response = http_root.get('/static/web-ui/testing.txt')
|
||||
assert response.status == 200
|
||||
os.remove(tmpfile)
|
||||
with patch('gns3server.utils.static.get_static_dir') as mock:
|
||||
mock.return_value = str(tmpdir)
|
||||
os.makedirs(str(tmpdir / 'web-ui'))
|
||||
tmpfile = static.get_static_path('web-ui/testing.txt')
|
||||
with open(tmpfile, 'w+') as f:
|
||||
f.write('world')
|
||||
response = http_root.get('/static/web-ui/testing.txt')
|
||||
assert response.status == 200
|
||||
|
||||
|
||||
def test_web_ui_not_found(http_root, tmpdir):
|
||||
|
Loading…
Reference in New Issue
Block a user