@@ -5955,6 +5955,43 @@ def test_create_challenge_using_github_when_user_is_not_authenticated(
59555955 self .assertEqual (list (response .data .values ())[0 ], expected ["error" ])
59565956 self .assertEqual (response .status_code , status .HTTP_401_UNAUTHORIZED )
59575957
5958+ def test_create_challenge_using_github_success (self ):
5959+ self .url = reverse_lazy (
5960+ "challenges:create_or_update_github_challenge" ,
5961+ kwargs = {"challenge_host_team_pk" : self .challenge_host_team .pk },
5962+ )
5963+
5964+ with mock .patch ("challenges.views.requests.get" ) as m :
5965+ resp = mock .Mock ()
5966+ resp .content = self .test_zip_file .read ()
5967+ resp .status_code = 200
5968+ m .return_value = resp
5969+ response = self .client .post (
5970+ self .url ,
5971+ {
5972+ "GITHUB_REPOSITORY" : "https://github.com/yourusername/repository" ,
5973+ "zip_configuration" : self .input_zip_file ,
5974+ },
5975+ format = "multipart" ,
5976+ )
5977+ expected = {
5978+ "Success" : "Challenge Challenge Title has been created successfully and sent for review to EvalAI Admin."
5979+ }
5980+
5981+ self .assertEqual (response .status_code , 201 )
5982+ self .assertEqual (response .json (), expected )
5983+ self .assertEqual (Challenge .objects .count (), 1 )
5984+ self .assertEqual (DatasetSplit .objects .count (), 1 )
5985+ self .assertEqual (Leaderboard .objects .count (), 1 )
5986+ self .assertEqual (ChallengePhaseSplit .objects .count (), 1 )
5987+
5988+ # Verify github_repository is properly stored
5989+ challenge = Challenge .objects .first ()
5990+ self .assertEqual (
5991+ challenge .github_repository ,
5992+ "https://github.com/yourusername/repository" ,
5993+ )
5994+
59585995
59595996class ValidateChallengeTest (APITestCase ):
59605997 def setUp (self ):
0 commit comments