diff --git a/tests/fixtures/payloads.py b/tests/fixtures/payloads.py index 708249d..5bb906a 100644 --- a/tests/fixtures/payloads.py +++ b/tests/fixtures/payloads.py @@ -296,7 +296,6 @@ } - release3 = { "name": "Another Created Release", "version": "99.06", @@ -306,4 +305,4 @@ "release_date": "2021-04-22", "esm_expires": "2022-01-31", "support_expires": "2022-01-31", -} \ No newline at end of file +} diff --git a/tests/test_routes.py b/tests/test_routes.py index 5d8c1a9..1f06edc 100644 --- a/tests/test_routes.py +++ b/tests/test_routes.py @@ -141,7 +141,8 @@ def test_cves_returns_200_for_non_existing_version(self): ) def test_cves_filtered_by_existing_version(self): - # Add releases because the DB only includes 1 release upon initialization + # Add releases because the DB only + # includes 1 release upon initialization add_release_response = self.client.post( "/security/releases.json", json=payloads.release ) @@ -156,7 +157,7 @@ def test_cves_filtered_by_existing_version(self): assert add_release2_response.status_code == 200 assert add_release3_response.status_code == 200 - # Add cves with different statuses because the + # Add cves with different statuses because the # DB only includes 1 cve upon initialization add_cves_response = self.client.put( "/security/cves.json", @@ -172,13 +173,15 @@ def test_cves_filtered_by_existing_version(self): ) assert add_cves_response.status_code == 200 - filtered_cves_response = self.client.get("/security/cves.json?version=testrelease") + filtered_cves_response = self.client.get( + "/security/cves.json?version=testrelease" + ) assert filtered_cves_response.status_code == 200 assert filtered_cves_response.json["total_results"] == 5 def text_cves_filtered_by_existing_status(self): - # Add cves with different statuses because the + # Add cves with different statuses because the # DB only includes 1 cve upon initialization add_cves_response = self.client.put( "/security/cves.json", @@ -194,13 +197,16 @@ def text_cves_filtered_by_existing_status(self): ) assert add_cves_response.status_code == 200 - filtered_cves_response = self.client.get("/security/cves.json?status=released") + filtered_cves_response = self.client.get( + "/security/cves.json?status=released" + ) assert filtered_cves_response.status_code == 200 assert filtered_cves_response.json["total_results"] == 6 def test_cves_filtered_by_multiple_statuses(self): - # Add releases because the DB only includes 1 release upon initialization + # Add releases because the DB only includes + # 1 release upon initialization add_release_response = self.client.post( "/security/releases.json", json=payloads.release ) @@ -215,7 +221,7 @@ def test_cves_filtered_by_multiple_statuses(self): assert add_release2_response.status_code == 200 assert add_release3_response.status_code == 200 - # Add cves with different statuses because the + # Add cves with different statuses because the # DB only includes 1 cve upon initialization add_cves_response = self.client.put( "/security/cves.json", @@ -232,13 +238,16 @@ def test_cves_filtered_by_multiple_statuses(self): assert add_cves_response.status_code == 200 - filtered_cves_response = self.client.get("/security/cves.json?status=needed&status=needs-triage") - + filtered_cves_response = self.client.get( + "/security/cves.json?status=needed&status=needs-triage" + ) + assert filtered_cves_response.status_code == 200 assert filtered_cves_response.json["total_results"] == 2 - + def test_cves_filtered_by_multiple_versions(self): - # Add releases because the DB only includes 1 release upon initialization + # Add releases because the DB only includes + # 1 release upon initialization add_release_response = self.client.post( "/security/releases.json", json=payloads.release ) @@ -252,8 +261,8 @@ def test_cves_filtered_by_multiple_versions(self): assert add_release_response.status_code == 200 assert add_release2_response.status_code == 200 assert add_release3_response.status_code == 200 - - # Add cves with different statuses because the + + # Add cves with different statuses because the # DB only includes 1 cve upon initialization add_cves_response = self.client.put( "/security/cves.json", @@ -270,13 +279,16 @@ def test_cves_filtered_by_multiple_versions(self): assert add_cves_response.status_code == 200 - filtered_cves_response = self.client.get("/security/cves.json?version=testrelease3&version=testrelease2") + filtered_cves_response = self.client.get( + "/security/cves.json?version=testrelease3&version=testrelease2" + ) assert filtered_cves_response.status_code == 200 assert filtered_cves_response.json["total_results"] == 3 def test_cves_filtered_by_status_and_version(self): - # Add releases because the DB only includes 1 release upon initialization + # Add releases because the DB only includes + # 1 release upon initialization add_release_response = self.client.post( "/security/releases.json", json=payloads.release ) @@ -291,7 +303,7 @@ def test_cves_filtered_by_status_and_version(self): assert add_release2_response.status_code == 200 assert add_release3_response.status_code == 200 - # Add cves with different statuses because the + # Add cves with different statuses because the # DB only includes 1 cve upon initialization add_cves_response = self.client.put( "/security/cves.json", @@ -308,8 +320,10 @@ def test_cves_filtered_by_status_and_version(self): assert add_cves_response.status_code == 200 - filtered_cves_response = self.client.get("/security/cves.json?status=needs-triage&version=testrelease2") - + filtered_cves_response = self.client.get( + "/security/cves.json?status=needs-triage&version=testrelease2" + ) + assert filtered_cves_response.status_code == 200 assert filtered_cves_response.json["total_results"] == 2 @@ -424,8 +438,9 @@ def test_cve_group_by_functionality(self): assert initial_cves.status_code == 200 assert initial_cves.json["cves"][0]["priority"] == "critical" - - # Add releases because the DB only includes 1 release upon initialization + + # Add releases because the DB only includes + # 1 release upon initialization add_release_response = self.client.post( "/security/releases.json", json=payloads.release ) diff --git a/webapp/views.py b/webapp/views.py index 3234f64..2c602c9 100644 --- a/webapp/views.py +++ b/webapp/views.py @@ -4,7 +4,7 @@ from flask import make_response, jsonify, request from flask_apispec import marshal_with, use_kwargs -from sqlalchemy import desc, or_, and_, case, asc +from sqlalchemy import desc, or_, case, asc from sqlalchemy.exc import DataError, IntegrityError from sqlalchemy.orm import load_only, selectinload, Query import dateutil