|  | 
| 9 | 9 |     with_rw_repo, | 
| 10 | 10 |     with_rw_and_rw_remote_repo, | 
| 11 | 11 |     fixture, | 
| 12 |  | -    GIT_DAEMON_PORT | 
|  | 12 | +    GIT_DAEMON_PORT, | 
|  | 13 | +    assert_raises | 
| 13 | 14 | ) | 
| 14 | 15 | from git import ( | 
| 15 | 16 |     RemoteProgress, | 
| @@ -62,7 +63,7 @@ def update(self, op_code, cur_count, max_count=None, message=''): | 
| 62 | 63 |         # check each stage only comes once | 
| 63 | 64 |         op_id = op_code & self.OP_MASK | 
| 64 | 65 |         assert op_id in (self.COUNTING, self.COMPRESSING, self.WRITING) | 
| 65 |  | -         | 
|  | 66 | + | 
| 66 | 67 |         if op_code & self.WRITING > 0: | 
| 67 | 68 |             if op_code & self.BEGIN > 0: | 
| 68 | 69 |                 assert not message, 'should not have message when remote begins writing' | 
| @@ -568,3 +569,47 @@ def test_uncommon_branch_names(self): | 
| 568 | 569 |         assert res[0].remote_ref_path == 'refs/pull/1/head' | 
| 569 | 570 |         assert res[0].ref.path == 'refs/heads/pull/1/head' | 
| 570 | 571 |         assert isinstance(res[0].ref, Head) | 
|  | 572 | + | 
|  | 573 | +    @with_rw_repo('HEAD', bare=False) | 
|  | 574 | +    def test_multiple_urls(self, rw_repo): | 
|  | 575 | +        # test addresses | 
|  | 576 | +        test1 = 'https://github.com/gitpython-developers/GitPython' | 
|  | 577 | +        test2 = 'https://github.com/gitpython-developers/gitdb' | 
|  | 578 | +        test3 = 'https://github.com/gitpython-developers/smmap' | 
|  | 579 | + | 
|  | 580 | +        remote = rw_repo.remotes[0] | 
|  | 581 | +        # Testing setting a single URL | 
|  | 582 | +        remote.set_url(test1) | 
|  | 583 | +        assert list(remote.urls) == [test1] | 
|  | 584 | + | 
|  | 585 | +        # Testing replacing that single URL | 
|  | 586 | +        remote.set_url(test1) | 
|  | 587 | +        assert list(remote.urls) == [test1] | 
|  | 588 | +        # Testing adding new URLs | 
|  | 589 | +        remote.set_url(test2, add=True) | 
|  | 590 | +        assert list(remote.urls) == [test1, test2] | 
|  | 591 | +        remote.set_url(test3, add=True) | 
|  | 592 | +        assert list(remote.urls) == [test1, test2, test3] | 
|  | 593 | +        # Testing removing an URL | 
|  | 594 | +        remote.set_url(test2, delete=True) | 
|  | 595 | +        assert list(remote.urls) == [test1, test3] | 
|  | 596 | +        # Testing changing an URL | 
|  | 597 | +        remote.set_url(test3, test2) | 
|  | 598 | +        assert list(remote.urls) == [test1, test2] | 
|  | 599 | + | 
|  | 600 | +        # will raise: fatal: --add --delete doesn't make sense | 
|  | 601 | +        assert_raises(GitCommandError, remote.set_url, test2, add=True, delete=True) | 
|  | 602 | + | 
|  | 603 | +        # Testing on another remote, with the add/delete URL | 
|  | 604 | +        remote = rw_repo.create_remote('another', url=test1) | 
|  | 605 | +        remote.add_url(test2) | 
|  | 606 | +        assert list(remote.urls) == [test1, test2] | 
|  | 607 | +        remote.add_url(test3) | 
|  | 608 | +        assert list(remote.urls) == [test1, test2, test3] | 
|  | 609 | +        # Testing removing all the URLs | 
|  | 610 | +        remote.delete_url(test2) | 
|  | 611 | +        assert list(remote.urls) == [test1, test3] | 
|  | 612 | +        remote.delete_url(test1) | 
|  | 613 | +        assert list(remote.urls) == [test3] | 
|  | 614 | +        # will raise fatal: Will not delete all non-push URLs | 
|  | 615 | +        assert_raises(GitCommandError, remote.delete_url, test3) | 
0 commit comments