Skip to content

Commit ab370fb

Browse files
committed
Created failing test to read tag and its challenge
1 parent f432cbe commit ab370fb

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

challenges/tests/test_requests/test_challenges.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_challenge_create(self):
5454

5555
def test_challenge_create_with_tags(self):
5656
"""
57-
Ensure we get the correct challenge
57+
Ensure we get the correct tags information with a challenge
5858
"""
5959
tag1 = Tag.objects.create(name='Javascript')
6060

@@ -75,7 +75,7 @@ def test_challenge_create_with_tags(self):
7575

7676
def test_challenge_create_with_source(self):
7777
"""
78-
Ensure we get the correct challenge
78+
Ensure we get the correct sources information with the challenge
7979
"""
8080
challenge = self.get_sample_challenge()
8181
source = Source.objects.create(
@@ -93,3 +93,25 @@ def test_challenge_create_with_source(self):
9393
included = response_data['included']
9494

9595
[item for item in included if item.get('type') == 'sources'][0]['attributes']['name'].should.equal(source.name)
96+
97+
def get_challenges_with_tag_name(self):
98+
"""
99+
Ensure we get the correct challenge
100+
"""
101+
tag = Tag.objects.create(name='testTag')
102+
103+
challenge1 = self.get_sample_challenge(tags=[ tag ])
104+
challenge2 = self.get_sample_challenge(tags=[ tag ])
105+
106+
response = self.client.get(f'/services/api/tags?pk={ tag.name }',
107+
content_type=self.content_type)
108+
109+
response.status_code.should.equal(200)
110+
111+
response_data = json.loads(response.content)
112+
attributes = response_data['data'][0]['attributes']
113+
included = response_data['included']
114+
115+
attributes['name'].should.equal(tag.name)
116+
117+
len([item for item in included if item.get('type') == 'challenge']).should.equal(2)

0 commit comments

Comments
 (0)