Skip to content

Commit

Permalink
filter tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvyshnevska committed Sep 18, 2023
1 parent e500e3d commit be70b05
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions profiles/tests/test_filter_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ def test_get_profiles_unauthorized_content(self):

def test_get_profiles_filter_companies_unauthorized_count(self):
response = self.client.get(
path="/api/profiles/?company=True&page=1&page_size=12")
path="/api/profiles/?is_registered=True&page=1&page_size=12")
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(1, response.data["total_items"])

def test_get_profiles_filter_companies_unauthorized_content(self):
response = self.client.get(
path="/api/profiles/?company=True&page=1&page_size=12")
path="/api/profiles/?is_registered=True&page=1&page_size=12")
ids_from_response = [prof["id"] for prof in response.data["results"]]
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual([self.company.id], ids_from_response)

def test_get_profiles_filter_startups_unauthorized_count(self):
response = self.client.get(
path="/api/profiles/?startup=True&page=1&page_size=12")
path="/api/profiles/?is_startup=True&page=1&page_size=12")
self.assertEqual(status.HTTP_200_OK, response.status_code)
# self.assertEqual(len(self.startup), response.data["total_items"])
self.assertEqual(1, response.data["total_items"])

def test_get_profiles_filter_startups_unauthorized_content(self):
response = self.client.get(
path="/api/profiles/?startup=True&page=1&page_size=12")
path="/api/profiles/?is_startup=True&page=1&page_size=12")
ids_from_response = [prof["id"] for prof in response.data["results"]]
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual([self.startup.id], ids_from_response)
Expand All @@ -62,7 +62,7 @@ def test_get_profiles_filter_companies_authorized_count(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?company=True&page=1&page_size=12")
path="/api/profiles/?is_registered=True&page=1&page_size=12")
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(2, response.data["total_items"], msg="Total result amount doesn't match.")
self.assertEqual(
Expand All @@ -75,7 +75,7 @@ def test_get_profiles_filter_companies_authorized_content(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?company=True&page=1&page_size=12")
path="/api/profiles/?is_registered=True&page=1&page_size=12")

saved_from_response = [company for company in response.data["results"] if company["is_saved"]]

Expand All @@ -93,7 +93,7 @@ def test_get_profiles_filter_companies_saved_authorized_count(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?company=True&is_saved=True&page=1&page_size=12")
path="/api/profiles/?is_registered=True&is_saved=True&page=1&page_size=12")
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(1, response.data["total_items"])

Expand All @@ -102,7 +102,7 @@ def test_get_profiles_filter_companies_saved_authorized_content(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?company=True&is_saved=True&page=1&page_size=12")
path="/api/profiles/?is_registered=True&is_saved=True&page=1&page_size=12")
saved_from_response = [company for company in response.data["results"] if company["is_saved"]]

self.assertEqual(status.HTTP_200_OK, response.status_code)
Expand All @@ -114,7 +114,7 @@ def test_get_profiles_filter_startups_authorized_count(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?startup=True&page=1&page_size=12")
path="/api/profiles/?is_startup=True&page=1&page_size=12")
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(2, response.data["total_items"])
self.assertEqual(
Expand All @@ -127,7 +127,7 @@ def test_get_profiles_filter_startups_authorized_content(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?startup=True&page=1&page_size=12")
path="/api/profiles/?is_startup=True&page=1&page_size=12")

saved_from_response = [startup for startup in response.data["results"] if startup["is_saved"]]

Expand All @@ -145,7 +145,7 @@ def test_get_profiles_filter_startups_saved_authorized_count(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?startup=True&is_saved=True&page=1&page_size=12".format(
path="/api/profiles/?is_startup=True&is_saved=True&page=1&page_size=12".format(
company_type="startup"))
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(1, response.data["total_items"])
Expand All @@ -155,7 +155,7 @@ def test_get_profiles_filter_startups_saved_authorized_content(self):
self.client.force_authenticate(self.user)

response = self.client.get(
path="/api/profiles/?startup=True&is_saved=True&page=1&page_size=12".format(
path="/api/profiles/?is_startup=True&is_saved=True&page=1&page_size=12".format(
company_type="startup"))
saved_from_response = [startup for startup in response.data["results"] if startup["is_saved"]]

Expand Down Expand Up @@ -193,14 +193,14 @@ def setUp(self) -> None:

def test_get_profiles_any_user_filter_producer_count(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="producer", page_size=self.page_size))
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.producers_number, response.data["total_items"])

def test_get_profiles_any_user_filter_producer_content(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="producer", page_size=self.page_size))
producers_from_db = Profile.objects.filter(
activities=self.producer_activity, is_deleted=False).order_by("id")
Expand All @@ -212,14 +212,14 @@ def test_get_profiles_any_user_filter_producer_content(self):

def test_get_profiles_any_user_filter_importer_count(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="importer", page_size=self.page_size))
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.importers_number, response.data["total_items"])

def test_get_profiles_any_user_filter_importer_content(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="importer", page_size=self.page_size))
importers_from_db = Profile.objects.filter(
activities=self.importer_activity, is_deleted=False).order_by("id")
Expand All @@ -231,14 +231,14 @@ def test_get_profiles_any_user_filter_importer_content(self):

def test_get_profiles_any_user_filter_retail_count(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="retail", page_size=self.page_size))
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.retailers_number, response.data["total_items"])

def test_get_profiles_any_user_filter_retail_content(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="retail", page_size=self.page_size))
retailers_from_db = Profile.objects.filter(
activities=self.retail_activity, is_deleted=False).order_by("id")
Expand All @@ -250,14 +250,14 @@ def test_get_profiles_any_user_filter_retail_content(self):

def test_get_profiles_any_user_filter_horeca_count(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="horeca", page_size=self.page_size))
self.assertEqual(status.HTTP_200_OK, response.status_code)
self.assertEqual(self.horecas_number, response.data["total_items"])

def test_get_profiles_any_user_filter_horeca_content(self):
response = self.client.get(
path="/api/profiles/?activity_type={activity}&page=1&page_size={page_size}".format(
path="/api/profiles/?activities__name={activity}&page=1&page_size={page_size}".format(
activity="horeca", page_size=self.page_size))
horecas_from_db = Profile.objects.filter(
activities=self.horeca_activity, is_deleted=False).order_by("id")
Expand Down

0 comments on commit be70b05

Please sign in to comment.