tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_get_mozilla_remote_args.py (1768B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 from unittest import mock
      6 
      7 import mozunit
      8 import pytest
      9 
     10 from mozversioncontrol import get_repository_object
     11 
     12 STEPS = {
     13    "hg": [],
     14    "git": [
     15        "git remote add blah https://example.com/blah",
     16        """
     17        git remote add unified hg::https://hg.mozilla.org/mozilla-unified
     18        git remote add central hg::https://hg.mozilla.org/central
     19        git remote add try hg::https://hg.mozilla.org/try
     20        git remote add firefox https://github.com/mozilla-firefox/firefox
     21        """,
     22    ],
     23    "jj": [],
     24 }
     25 
     26 
     27 @pytest.mark.parametrize(
     28    "is_cinnabar,expected_remotes",
     29    (
     30        (
     31            True,
     32            [
     33                "--remotes=central",
     34                "--remotes=firefox",
     35                "--remotes=unified",
     36            ],
     37        ),
     38        (False, ["--remotes=firefox"]),
     39    ),
     40 )
     41 def test_get_mozilla_remote_args(is_cinnabar, expected_remotes, repo):
     42    # Test is only relevant for Git.
     43    if not repo.vcs == "git":
     44        return
     45 
     46    repo.execute_next_step()
     47 
     48    vcs = get_repository_object(repo.dir)
     49    vcs.is_cinnabar_repo = mock.MagicMock(name="is_cinnabar_repo")
     50    vcs.is_cinnabar_repo.return_value = is_cinnabar
     51 
     52    remotes = vcs.get_mozilla_remote_args()
     53 
     54    assert remotes == ["--remotes"], (
     55        "Default `--remotes` passed without finding official remote."
     56    )
     57 
     58    repo.execute_next_step()
     59 
     60    remotes = sorted(vcs.get_mozilla_remote_args())
     61 
     62    assert remotes == expected_remotes, (
     63        "Multiple non-try remote arguments should be found."
     64    )
     65 
     66 
     67 if __name__ == "__main__":
     68    mozunit.main()