@@ -1044,25 +1044,6 @@ def test_git_cli_clone_fork_and_branch_non_existing_remote_existing_target_dir(c
1044
1044
assert "trying to reset hard" in caplog .text
1045
1045
1046
1046
1047
- def test_git_platform_backend_get_remote_url_https ():
1048
- owner = "OWNER"
1049
- repo = "REPO"
1050
-
1051
- url = GitPlatformBackend .get_remote_url (owner , repo , GitConnectionMode .HTTPS )
1052
-
1053
- assert url == f"https://github.com/{ owner } /{ repo } .git"
1054
-
1055
-
1056
- def test_git_platform_backend_get_remote_url_token ():
1057
- owner = "OWNER"
1058
- repo = "REPO"
1059
- token = "TOKEN"
1060
-
1061
- url = GitPlatformBackend .get_remote_url (owner , repo , GitConnectionMode .HTTPS , token )
1062
-
1063
- assert url == f"https://{ token } @github.com/{ owner } /{ repo } .git"
1064
-
1065
-
1066
1047
def test_github_backend_from_token ():
1067
1048
token = "TOKEN"
1068
1049
@@ -1106,6 +1087,27 @@ def test_github_backend_does_repository_exist(does_exist: bool):
1106
1087
github3_client .repository .assert_called_once_with ("OWNER" , "REPO" )
1107
1088
1108
1089
1090
+ def test_github_backend_get_remote_url_https ():
1091
+ owner = "OWNER"
1092
+ repo = "REPO"
1093
+ backend = GitHubBackend (MagicMock (), MagicMock (), "" )
1094
+
1095
+ url = backend .get_remote_url (owner , repo , GitConnectionMode .HTTPS )
1096
+
1097
+ assert url == f"https://github.com/{ owner } /{ repo } .git"
1098
+
1099
+
1100
+ def test_github_backend_get_remote_url_token ():
1101
+ owner = "OWNER"
1102
+ repo = "REPO"
1103
+ token = "TOKEN"
1104
+ backend = GitHubBackend (MagicMock (), MagicMock (), "" )
1105
+
1106
+ url = backend .get_remote_url (owner , repo , GitConnectionMode .HTTPS , token )
1107
+
1108
+ assert url == f"https://{ token } @github.com/{ owner } /{ repo } .git"
1109
+
1110
+
1109
1111
@mock .patch ("time.sleep" , return_value = None )
1110
1112
@mock .patch (
1111
1113
"conda_forge_tick.git_utils.GitHubBackend.user" , new_callable = mock .PropertyMock
@@ -1609,6 +1611,48 @@ def test_dry_run_backend_does_repository_exist_other_repo():
1609
1611
)
1610
1612
1611
1613
1614
+ @pytest .mark .parametrize ("token" , [None , "TOKEN" ])
1615
+ def test_dry_run_backend_get_remote_url_non_fork (token : str | None ):
1616
+ backend = DryRunBackend ()
1617
+
1618
+ url = backend .get_remote_url ("OWNER" , "REPO" , GitConnectionMode .HTTPS , token )
1619
+
1620
+ if token is None :
1621
+ assert url == "https://github.com/OWNER/REPO.git"
1622
+ else :
1623
+ assert url == "https://[email protected] /OWNER/REPO.git"
1624
+
1625
+
1626
+ @pytest .mark .parametrize ("token" , [None , "TOKEN" ])
1627
+ def test_dry_run_backend_get_remote_url_non_existing_fork (token : str | None ):
1628
+ backend = DryRunBackend ()
1629
+
1630
+ with pytest .raises (RepositoryNotFoundError , match = "does not exist" ):
1631
+ backend .get_remote_url (backend .user , "REPO" , GitConnectionMode .HTTPS , token )
1632
+
1633
+ backend .fork ("UPSTREAM_OWNER" , "REPO2" )
1634
+
1635
+ with pytest .raises (RepositoryNotFoundError , match = "does not exist" ):
1636
+ backend .get_remote_url (backend .user , "REPO" , GitConnectionMode .HTTPS , token )
1637
+
1638
+
1639
+ @pytest .mark .parametrize ("token" , [None , "TOKEN" ])
1640
+ def test_dry_run_backend_get_remote_url_existing_fork (token : str | None ):
1641
+ backend = DryRunBackend ()
1642
+
1643
+ backend .fork ("UPSTREAM_OWNER" , "pytest-feedstock" )
1644
+
1645
+ url = backend .get_remote_url (
1646
+ backend .user , "pytest-feedstock" , GitConnectionMode .HTTPS , token
1647
+ )
1648
+
1649
+ # note that the URL does not indicate anymore that it is a fork
1650
+ assert (
1651
+ url
1652
+ == f"https://{ f'{ token } @' if token else '' } github.com/UPSTREAM_OWNER/pytest-feedstock.git"
1653
+ )
1654
+
1655
+
1612
1656
def test_dry_run_backend_push_to_repository (caplog ):
1613
1657
caplog .set_level (logging .DEBUG )
1614
1658
0 commit comments