mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 02:47:10 +00:00
Merge branch 'master' of gitlab.prodcontest.ru:team-15/project
This commit is contained in:
@@ -101,7 +101,7 @@ class CompetitionsEndpointTests(TestCase):
|
||||
self.user = User.objects.create(
|
||||
email="user@example.com",
|
||||
password=make_password("password123"),
|
||||
username="t1wk4"
|
||||
username="t1wk4",
|
||||
)
|
||||
|
||||
resp = self.client.post(
|
||||
@@ -118,7 +118,8 @@ class CompetitionsEndpointTests(TestCase):
|
||||
title=f"Competition {i}",
|
||||
description=f"Description {i}",
|
||||
type=(
|
||||
Competition.CompetitionType.EDU if i % 2 == 0
|
||||
Competition.CompetitionType.EDU
|
||||
if i % 2 == 0
|
||||
else Competition.CompetitionType.COMPETITIVE
|
||||
),
|
||||
participation_type=Competition.CompetitionParticipationType.SOLO,
|
||||
@@ -129,9 +130,7 @@ class CompetitionsEndpointTests(TestCase):
|
||||
competition.participants.add(self.user)
|
||||
self.competitions.append(competition)
|
||||
|
||||
self.valid_headers = {
|
||||
"HTTP_AUTHORIZATION": f"Bearer {token}"
|
||||
}
|
||||
self.valid_headers = {"HTTP_AUTHORIZATION": f"Bearer {token}"}
|
||||
|
||||
def get_url(self, params=None):
|
||||
base_url = "/api/v1/competitions"
|
||||
@@ -139,8 +138,7 @@ class CompetitionsEndpointTests(TestCase):
|
||||
|
||||
def test_get_participating_competitions(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=true"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=true"), **self.valid_headers
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@@ -148,13 +146,12 @@ class CompetitionsEndpointTests(TestCase):
|
||||
self.assertEqual(len(data), 2)
|
||||
self.assertEqual(
|
||||
{item["id"] for item in data},
|
||||
{str(self.competitions[0].id), str(self.competitions[1].id)}
|
||||
{str(self.competitions[0].id), str(self.competitions[1].id)},
|
||||
)
|
||||
|
||||
def test_competition_type_values(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=true"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=true"), **self.valid_headers
|
||||
)
|
||||
|
||||
for item in response.json():
|
||||
@@ -162,20 +159,15 @@ class CompetitionsEndpointTests(TestCase):
|
||||
|
||||
def test_participation_type_values(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=false"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=false"), **self.valid_headers
|
||||
)
|
||||
|
||||
types = [item["participation_type"] for item in response.json()]
|
||||
self.assertCountEqual(
|
||||
types,
|
||||
["solo", "solo", "solo"]
|
||||
)
|
||||
self.assertCountEqual(types, ["solo", "solo", "solo"])
|
||||
|
||||
def test_datetime_formatting(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=true"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=true"), **self.valid_headers
|
||||
)
|
||||
|
||||
for item in response.json():
|
||||
@@ -192,8 +184,7 @@ class CompetitionsEndpointTests(TestCase):
|
||||
|
||||
def test_competition_metadata(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=true"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=true"), **self.valid_headers
|
||||
)
|
||||
|
||||
item = response.json()[0]
|
||||
@@ -204,8 +195,7 @@ class CompetitionsEndpointTests(TestCase):
|
||||
|
||||
def test_verbose_name_consistency(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=true"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=true"), **self.valid_headers
|
||||
)
|
||||
|
||||
item = response.json()[0]
|
||||
@@ -217,16 +207,16 @@ class CompetitionsEndpointTests(TestCase):
|
||||
title="No Dates Competition",
|
||||
description="Test competition",
|
||||
type=Competition.CompetitionType.EDU,
|
||||
participation_type=Competition.CompetitionParticipationType.SOLO
|
||||
participation_type=Competition.CompetitionParticipationType.SOLO,
|
||||
)
|
||||
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=false"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=false"), **self.valid_headers
|
||||
)
|
||||
|
||||
test_item = next(
|
||||
item for item in response.json()
|
||||
item
|
||||
for item in response.json()
|
||||
if item["id"] == str(competition.id)
|
||||
)
|
||||
self.assertIsNone(test_item["start_date"])
|
||||
@@ -234,8 +224,7 @@ class CompetitionsEndpointTests(TestCase):
|
||||
|
||||
def test_participation_status_filtering(self):
|
||||
response = self.client.get(
|
||||
self.get_url("is_participating=false"),
|
||||
**self.valid_headers
|
||||
self.get_url("is_participating=false"), **self.valid_headers
|
||||
)
|
||||
|
||||
data = response.json()
|
||||
|
||||
Reference in New Issue
Block a user