From 0daed53b310058ca0750b66f754dc49f4d635581 Mon Sep 17 00:00:00 2001 From: Jozef Dochan Date: Sat, 17 Feb 2018 13:48:25 +0100 Subject: [PATCH] increased coverage --- tests.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests.py b/tests.py index 7d6de4b..c0434cf 100644 --- a/tests.py +++ b/tests.py @@ -16,6 +16,11 @@ def setUp(self): def make_request(self, data): return self.app.post("/download/", data=json.dumps(data), headers=self.headers) + def make_wrong_request(self, data): + return self.app.post("/download/", data=json.dumps(data), headers={ + "Content-Type": "application/json" + }) + def test_invalid_url(self): tmp = self.make_request(dict( url="https://mrose" @@ -27,11 +32,14 @@ def test_landing_page(self): assert tmp.status_code == 200 def test_general_download(self): + old = app.conf["local_network_without_login"] + app.conf["local_network_without_login"] = False tmp = self.make_request(dict( url="http://theglow666.6f.sk/image_test/", name="test", category="test" )) + app.conf["local_network_without_login"] = old assert tmp.status_code == 200 def test_general_download_without_name(self): @@ -42,21 +50,17 @@ def test_general_download_without_name(self): assert tmp.status_code == 200 def test_download_without_auth_local(self): - tmp = self.app.post("/download/", data=json.dumps(dict( + tmp = self.make_wrong_request(dict( url="https://mrose.org/cc/png-test.png" - )), headers={ - "Content-Type": "application/json" - }) + )) assert tmp.status_code == 200 def test_download_without_auth_remote(self): old = app.conf["local_network_without_login"] app.conf["local_network_without_login"] = False - tmp = self.app.post("/download/", data=json.dumps(dict( + tmp = self.make_wrong_request(dict( url="https://mrose.org/cc/png-test.png" - )), headers={ - "Content-Type": "application/json" - }) + )) app.conf["local_network_without_login"] = old assert tmp.status_code == 401