From 25adc65c6dfc99c3bed900602651a19fbb4a620a Mon Sep 17 00:00:00 2001 From: Amir Karimi Date: Thu, 31 Oct 2024 01:43:47 +0330 Subject: [PATCH] fix: fix ci.yml linter --- tests/test_app.py | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/tests/test_app.py b/tests/test_app.py index 24df212..f31f07d 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -23,9 +23,7 @@ def test_successful_request(self, mock_post): "chat": "The previous chat context.", } - response = self.app.post( - "/process", data=json.dumps(data), content_type="application/json" - ) + response = self.app.post("/process", data=json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 200) self.assertEqual(response.json, {"status": True}) @@ -42,9 +40,7 @@ def test_successful_request_malicious(self, mock_post): "chat": "The previous chat context.", } - response = self.app.post( - "/process", data=json.dumps(data), content_type="application/json" - ) + response = self.app.post("/process", data=json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 200) self.assertEqual(response.json, {"status": False}) @@ -61,16 +57,12 @@ def test_missing_response_field(self, mock_post): "chat": "The previous chat context.", } - response = self.app.post( - "/process", data=json.dumps(data), content_type="application/json" - ) + response = self.app.post("/process", data=json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 500) self.assertEqual( response.json, - { - "error": "Internal server error. Missing 'response' field in external API response" - }, + {"error": "Internal server error. Missing 'response' field in external API response"}, ) @patch("requests.post") @@ -85,16 +77,12 @@ def test_no_number_in_response(self, mock_post): "chat": "The previous chat context.", } - response = self.app.post( - "/process", data=json.dumps(data), content_type="application/json" - ) + response = self.app.post("/process", data=json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 500) self.assertEqual( response.json, - { - "error": "Internal server error. No number in the range [0, 100] found in response" - }, + {"error": "Internal server error. No number in the range [0, 100] found in response"}, ) @patch("requests.post") @@ -109,29 +97,21 @@ def test_invalid_number_in_response(self, mock_post): "chat": "The previous chat context.", } - response = self.app.post( - "/process", data=json.dumps(data), content_type="application/json" - ) + response = self.app.post("/process", data=json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 500) self.assertEqual( response.json, - { - "error": "Internal server error. No number in the range [0, 100] found in response" - }, + {"error": "Internal server error. No number in the range [0, 100] found in response"}, ) def test_invalid_input(self): data = {"chat": "The previous chat context."} - response = self.app.post( - "/process", data=json.dumps(data), content_type="application/json" - ) + response = self.app.post("/process", data=json.dumps(data), content_type="application/json") self.assertEqual(response.status_code, 400) - self.assertEqual( - response.json, {"error": "Invalid input, 'prompt' and 'chat' are required"} - ) + self.assertEqual(response.json, {"error": "Invalid input, 'prompt' and 'chat' are required"}) if __name__ == "__main__":