@@ -54,7 +54,7 @@ def test_challenge_create(self):
54
54
55
55
def test_challenge_create_with_tags (self ):
56
56
"""
57
- Ensure we get the correct challenge
57
+ Ensure we get the correct tags information with a challenge
58
58
"""
59
59
tag1 = Tag .objects .create (name = 'Javascript' )
60
60
@@ -75,7 +75,7 @@ def test_challenge_create_with_tags(self):
75
75
76
76
def test_challenge_create_with_source (self ):
77
77
"""
78
- Ensure we get the correct challenge
78
+ Ensure we get the correct sources information with the challenge
79
79
"""
80
80
challenge = self .get_sample_challenge ()
81
81
source = Source .objects .create (
@@ -93,3 +93,25 @@ def test_challenge_create_with_source(self):
93
93
included = response_data ['included' ]
94
94
95
95
[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