@@ -205,11 +205,14 @@ def test_get_challenge(self):
205205 "worker_instance_type" : self .challenge .worker_instance_type ,
206206 "sqs_retention_period" : self .challenge .sqs_retention_period ,
207207 "github_repository" : self .challenge .github_repository ,
208+ "github_branch" : self .challenge .github_branch ,
208209 }
209210 ]
210211
211212 response = self .client .get (self .url , {})
212- self .assertEqual (response .data ["results" ], expected )
213+ self .assertEqual (
214+ response .data ["results" ], json .loads (json .dumps (expected ))
215+ )
213216 self .assertEqual (response .status_code , status .HTTP_200_OK )
214217
215218 def test_particular_challenge_host_team_for_challenge_does_not_exist (self ):
@@ -577,6 +580,7 @@ def test_get_particular_challenge(self):
577580 "worker_instance_type" : self .challenge .worker_instance_type ,
578581 "sqs_retention_period" : self .challenge .sqs_retention_period ,
579582 "github_repository" : self .challenge .github_repository ,
583+ "github_branch" : self .challenge .github_branch ,
580584 }
581585 response = self .client .get (self .url , {})
582586 self .assertEqual (response .data , expected )
@@ -680,6 +684,7 @@ def test_update_challenge_when_user_is_its_creator(self):
680684 "worker_instance_type" : self .challenge .worker_instance_type ,
681685 "sqs_retention_period" : self .challenge .sqs_retention_period ,
682686 "github_repository" : self .challenge .github_repository ,
687+ "github_branch" : self .challenge .github_branch ,
683688 }
684689 response = self .client .put (
685690 self .url , {"title" : new_title , "description" : new_description }
@@ -809,6 +814,7 @@ def test_particular_challenge_partial_update(self):
809814 "worker_instance_type" : self .challenge .worker_instance_type ,
810815 "sqs_retention_period" : self .challenge .sqs_retention_period ,
811816 "github_repository" : self .challenge .github_repository ,
817+ "github_branch" : self .challenge .github_branch ,
812818 }
813819 response = self .client .patch (self .url , self .partial_update_data )
814820 self .assertEqual (response .data , expected )
@@ -887,6 +893,7 @@ def test_particular_challenge_update(self):
887893 "worker_instance_type" : self .challenge .worker_instance_type ,
888894 "sqs_retention_period" : self .challenge .sqs_retention_period ,
889895 "github_repository" : self .challenge .github_repository ,
896+ "github_branch" : self .challenge .github_branch ,
890897 }
891898 response = self .client .put (self .url , self .data )
892899 self .assertEqual (response .data , expected )
@@ -1484,6 +1491,7 @@ def test_get_past_challenges(self):
14841491 "worker_instance_type" : self .challenge3 .worker_instance_type ,
14851492 "sqs_retention_period" : self .challenge3 .sqs_retention_period ,
14861493 "github_repository" : self .challenge3 .github_repository ,
1494+ "github_branch" : self .challenge3 .github_branch ,
14871495 }
14881496 ]
14891497 response = self .client .get (self .url , {}, format = "json" )
@@ -1568,6 +1576,7 @@ def test_get_present_challenges(self):
15681576 "worker_instance_type" : self .challenge2 .worker_instance_type ,
15691577 "sqs_retention_period" : self .challenge2 .sqs_retention_period ,
15701578 "github_repository" : self .challenge2 .github_repository ,
1579+ "github_branch" : self .challenge2 .github_branch ,
15711580 }
15721581 ]
15731582 response = self .client .get (self .url , {}, format = "json" )
@@ -1652,6 +1661,7 @@ def test_get_future_challenges(self):
16521661 "worker_instance_type" : self .challenge4 .worker_instance_type ,
16531662 "sqs_retention_period" : self .challenge4 .sqs_retention_period ,
16541663 "github_repository" : self .challenge4 .github_repository ,
1664+ "github_branch" : self .challenge4 .github_branch ,
16551665 }
16561666 ]
16571667 response = self .client .get (self .url , {}, format = "json" )
@@ -1736,6 +1746,7 @@ def test_get_all_challenges(self):
17361746 "worker_instance_type" : self .challenge4 .worker_instance_type ,
17371747 "sqs_retention_period" : self .challenge4 .sqs_retention_period ,
17381748 "github_repository" : self .challenge4 .github_repository ,
1749+ "github_branch" : self .challenge4 .github_branch ,
17391750 },
17401751 {
17411752 "id" : self .challenge3 .pk ,
@@ -1804,6 +1815,7 @@ def test_get_all_challenges(self):
18041815 "worker_instance_type" : self .challenge3 .worker_instance_type ,
18051816 "sqs_retention_period" : self .challenge3 .sqs_retention_period ,
18061817 "github_repository" : self .challenge3 .github_repository ,
1818+ "github_branch" : self .challenge3 .github_branch ,
18071819 },
18081820 {
18091821 "id" : self .challenge2 .pk ,
@@ -1872,6 +1884,7 @@ def test_get_all_challenges(self):
18721884 "worker_instance_type" : self .challenge2 .worker_instance_type ,
18731885 "sqs_retention_period" : self .challenge2 .sqs_retention_period ,
18741886 "github_repository" : self .challenge2 .github_repository ,
1887+ "github_branch" : self .challenge2 .github_branch ,
18751888 },
18761889 ]
18771890 response = self .client .get (self .url , {}, format = "json" )
@@ -2012,6 +2025,7 @@ def test_get_featured_challenges(self):
20122025 "worker_instance_type" : self .challenge3 .worker_instance_type ,
20132026 "sqs_retention_period" : self .challenge3 .sqs_retention_period ,
20142027 "github_repository" : self .challenge3 .github_repository ,
2028+ "github_branch" : self .challenge3 .github_branch ,
20152029 }
20162030 ]
20172031 response = self .client .get (self .url , {}, format = "json" )
@@ -2177,6 +2191,7 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self):
21772191 "worker_instance_type" : self .challenge3 .worker_instance_type ,
21782192 "sqs_retention_period" : self .challenge3 .sqs_retention_period ,
21792193 "github_repository" : self .challenge3 .github_repository ,
2194+ "github_branch" : self .challenge3 .github_branch ,
21802195 }
21812196
21822197 response = self .client .get (self .url , {})
@@ -2269,6 +2284,7 @@ def test_get_challenge_by_pk_when_user_is_participant(self):
22692284 "worker_instance_type" : self .challenge4 .worker_instance_type ,
22702285 "sqs_retention_period" : self .challenge4 .sqs_retention_period ,
22712286 "github_repository" : self .challenge4 .github_repository ,
2287+ "github_branch" : self .challenge4 .github_branch ,
22722288 }
22732289
22742290 self .client .force_authenticate (user = self .user1 )
@@ -2423,6 +2439,7 @@ def test_get_challenge_when_host_team_is_given(self):
24232439 "worker_instance_type" : self .challenge2 .worker_instance_type ,
24242440 "sqs_retention_period" : self .challenge2 .sqs_retention_period ,
24252441 "github_repository" : self .challenge2 .github_repository ,
2442+ "github_branch" : self .challenge2 .github_branch ,
24262443 }
24272444 ]
24282445
@@ -2503,6 +2520,7 @@ def test_get_challenge_when_participant_team_is_given(self):
25032520 "worker_instance_type" : self .challenge2 .worker_instance_type ,
25042521 "sqs_retention_period" : self .challenge2 .sqs_retention_period ,
25052522 "github_repository" : self .challenge2 .github_repository ,
2523+ "github_branch" : self .challenge2 .github_branch ,
25062524 }
25072525 ]
25082526
@@ -2583,6 +2601,7 @@ def test_get_challenge_when_mode_is_participant(self):
25832601 "worker_instance_type" : self .challenge2 .worker_instance_type ,
25842602 "sqs_retention_period" : self .challenge2 .sqs_retention_period ,
25852603 "github_repository" : self .challenge2 .github_repository ,
2604+ "github_branch" : self .challenge2 .github_branch ,
25862605 }
25872606 ]
25882607
@@ -2661,6 +2680,7 @@ def test_get_challenge_when_mode_is_host(self):
26612680 "worker_instance_type" : self .challenge .worker_instance_type ,
26622681 "sqs_retention_period" : self .challenge .sqs_retention_period ,
26632682 "github_repository" : self .challenge .github_repository ,
2683+ "github_branch" : self .challenge .github_branch ,
26642684 },
26652685 {
26662686 "id" : self .challenge2 .pk ,
@@ -2729,6 +2749,7 @@ def test_get_challenge_when_mode_is_host(self):
27292749 "worker_instance_type" : self .challenge2 .worker_instance_type ,
27302750 "sqs_retention_period" : self .challenge2 .sqs_retention_period ,
27312751 "github_repository" : self .challenge2 .github_repository ,
2752+ "github_branch" : self .challenge2 .github_branch ,
27322753 },
27332754 ]
27342755
@@ -5911,6 +5932,7 @@ def test_create_challenge_using_github_success(self):
59115932 self .url ,
59125933 {
59135934 "GITHUB_REPOSITORY" : "https://github.com/yourusername/repository" ,
5935+ "GITHUB_BRANCH_NAME" : "refs/heads/challenge" ,
59145936 "zip_configuration" : self .input_zip_file ,
59155937 },
59165938 format = "multipart" ,
@@ -5926,6 +5948,14 @@ def test_create_challenge_using_github_success(self):
59265948 self .assertEqual (Leaderboard .objects .count (), 1 )
59275949 self .assertEqual (ChallengePhaseSplit .objects .count (), 1 )
59285950
5951+ # Verify github_branch is properly stored
5952+ challenge = Challenge .objects .first ()
5953+ self .assertEqual (
5954+ challenge .github_repository ,
5955+ "https://github.com/yourusername/repository" ,
5956+ )
5957+ self .assertEqual (challenge .github_branch , "refs/heads/challenge" )
5958+
59295959 def test_create_challenge_using_github_when_challenge_host_team_does_not_exist (
59305960 self ,
59315961 ):
@@ -5964,6 +5994,40 @@ def test_create_challenge_using_github_when_user_is_not_authenticated(
59645994 self .assertEqual (list (response .data .values ())[0 ], expected ["error" ])
59655995 self .assertEqual (response .status_code , status .HTTP_401_UNAUTHORIZED )
59665996
5997+ def test_create_challenge_using_github_without_branch_name (self ):
5998+ self .url = reverse_lazy (
5999+ "challenges:create_or_update_github_challenge" ,
6000+ kwargs = {"challenge_host_team_pk" : self .challenge_host_team .pk },
6001+ )
6002+
6003+ with mock .patch ("challenges.views.requests.get" ) as m :
6004+ resp = mock .Mock ()
6005+ resp .content = self .test_zip_file .read ()
6006+ resp .status_code = 200
6007+ m .return_value = resp
6008+ response = self .client .post (
6009+ self .url ,
6010+ {
6011+ "GITHUB_REPOSITORY" : "https://github.com/yourusername/repository" ,
6012+ "zip_configuration" : self .input_zip_file ,
6013+ },
6014+ format = "multipart" ,
6015+ )
6016+ expected = {
6017+ "Success" : "Challenge Challenge Title has been created successfully and sent for review to EvalAI Admin."
6018+ }
6019+
6020+ self .assertEqual (response .status_code , 201 )
6021+ self .assertEqual (response .json (), expected )
6022+
6023+ # Verify github_branch defaults to empty string when not provided
6024+ challenge = Challenge .objects .first ()
6025+ self .assertEqual (
6026+ challenge .github_repository ,
6027+ "https://github.com/yourusername/repository" ,
6028+ )
6029+ self .assertEqual (challenge .github_branch , "" )
6030+
59676031
59686032class ValidateChallengeTest (APITestCase ):
59696033 def setUp (self ):
@@ -6030,6 +6094,7 @@ def test_validate_challenge_using_success(self):
60306094 self .url ,
60316095 {
60326096 "GITHUB_REPOSITORY" : "https://github.com/yourusername/repository" ,
6097+ "GITHUB_BRANCH_NAME" : "refs/heads/challenge" ,
60336098 "zip_configuration" : self .input_zip_file ,
60346099 },
60356100 format = "multipart" ,
0 commit comments