From 41026c74c1fa7d1db294ac450efe02d25efdaa3d Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 26 Jun 2018 13:13:19 +0200 Subject: [PATCH] Use mocked dir for web-ui redirection test --- tests/handlers/test_index.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/handlers/test_index.py b/tests/handlers/test_index.py index ad7bebb7..774d3ffd 100644 --- a/tests/handlers/test_index.py +++ b/tests/handlers/test_index.py @@ -62,9 +62,16 @@ def test_web_ui(http_root, tmpdir): def test_web_ui_not_found(http_root, tmpdir): - response = http_root.get('/static/web-ui/not-found.txt') - # should serve web-ui/index.html - assert response.status == 200 + 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/index.html') + with open(tmpfile, 'w+') as f: + f.write('world') + + response = http_root.get('/static/web-ui/not-found.txt') + # should serve web-ui/index.html + assert response.status == 200 def test_v1(http_root):