Beispiel #1
0
    def test_disambiguate_with_abbreviated_site(self):
        with self.config:
            self.config.get_workspaces('bitbucket').returns(['ripio-test'])
            self.config.get_workspaces('github').returns(['ripio-test'])

        sut = ripio.Completion('gh:ripio', self.config)
        self.assertEquals(sut.found, ['github:ripio-test/ripio'])
Beispiel #2
0
    def test_public_repo_and_default_bitbucket_workspace(self):
        with self.config:
            self.config.get_credentials('bitbucket').returns(
                ripio.Credentials(BITBUCKET_CREDENTIALS))

        sut = ripio.Completion('ripio', self.config)
        self.assertEquals(sut.found, ['bitbucket:DavidVilla/ripio'])
Beispiel #3
0
    def test_bitbucket_private_repo_without_credentials(self):
        with self.config:
            self.config.get_workspaces('bitbucket').returns(['ripio-test'])

        sut = ripio.Completion('private', self.config)
        self.assertEquals(sut.found, [])
        self.assertEquals(sut.denied, ['bitbucket:ripio-test/private'])
Beispiel #4
0
    def test_one_match(self):
        with self.config:
            self.config.get_workspaces('bitbucket').returns(
                ['DavidVilla', 'ripio-test'])

        sut = ripio.Completion('repo0', self.config)
        self.assertEquals(sut.found, ['bitbucket:ripio-test/repo0'])
Beispiel #5
0
def get_repo(config, name=None, guess=True):
    name = name or config.repo
    try:
        repo_ref = ripio.RepoRef(name)
        print(f"- repository identity is '{repo_ref}'")

    except ripio.BadRepositoryName:
        if not guess:
            raise

        # FIXME: refactor this handler
        print(f"- trying to complete '{name}' at known workspaces...")
        completion = ripio.Completion(name, config.config_file)

        if len(completion.found) == 1:
            repo_ref = ripio.RepoRef(completion.found[0])
            print("- guessing '{}'".format(repo_ref))

        elif len(completion.found) > 1:
            print("- serveral completions found:")
            for r in completion.found:
                print(f"  - {r}")
            sys.exit(1)

    return ripio.Repo.make(repo_ref, config.credentials)
Beispiel #6
0
    def test_github_private_repo_without_credentials(self):
        with self.config as c:
            c.get_workspaces('github').returns(['ripio-test'])

        with self.assertRaises(ripio.WrongCompletion):
            sut = ripio.Completion('private', self.config)
            self.assertEquals(sut.found, [])
            self.assertEquals(sut.denied, ['github:ripio-test/private'])
Beispiel #7
0
    def test_match_in_two_sites(self):
        with self.config:
            self.config.get_workspaces('bitbucket').returns(['ripio-test'])
            self.config.get_workspaces('github').returns(['ripio-test'])

        sut = ripio.Completion('ripio', self.config)
        self.assertEquals(
            sut.found,
            ['bitbucket:ripio-test/ripio', 'github:ripio-test/ripio'])
Beispiel #8
0
    def test_no_matches(self):
        with self.config:
            self.config.get_workspaces('bitbucket').returns(['ripio-test'])

        with self.assertRaises(ripio.WrongCompletion):
            ripio.Completion('missing', self.config)
Beispiel #9
0
 def test_no_workspaces_in_config(self):
     with self.assertRaises(ripio.ConfigError):
         ripio.Completion('repo0', self.config)