Skip to content

Commit

Permalink
fix: fix ci.yml linter
Browse files Browse the repository at this point in the history
  • Loading branch information
AMK9978 committed Oct 30, 2024
1 parent 7eaafa7 commit 25adc65
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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})
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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__":
Expand Down

0 comments on commit 25adc65

Please sign in to comment.