# HG changeset patch # User Thomas De Schampheleire # Date 2018-02-11 13:54:19 # Node ID 91603c55aa61ef778787b42bd5d7bb58f1457282 # Parent 4086efa27652a0883e0194533fcd52edcabd13ba tests: api: cover original behavior for 'pull' Up to commit 85d812ab4c64, the api 'pull' method can either pull from the repository's specified remote (clone_uri) or, if the repository is a fork, from the fork origin. The existing test case only covered pulling from a remote, and pulling from a repo (non-fork) that does not have a remote specified. Update the test method naming to clarify this, and add a test to pull from a fork. diff --git a/kallithea/tests/api/api_base.py b/kallithea/tests/api/api_base.py --- a/kallithea/tests/api/api_base.py +++ b/kallithea/tests/api/api_base.py @@ -276,7 +276,7 @@ class _BaseTestApi(object): expected = 'userid is not the same as your user' self._compare_error(id_, expected, given=response.body) - def test_api_pull(self): + def test_api_pull_remote(self): repo_name = u'test_pull' r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) r.clone_uri = os.path.join(Ui.get_by_key('paths', '/').ui_value, self.REPO) @@ -292,7 +292,21 @@ class _BaseTestApi(object): fixture.destroy_repo(repo_name) - def test_api_pull_error(self): + def test_api_pull_fork(self): + fork_name = u'fork' + fixture.create_fork(self.REPO, fork_name) + id_, params = _build_data(self.apikey, 'pull', + repoid=fork_name,) + response = api_call(self, params) + + expected = {'msg': 'Pulled from `%s`' % fork_name, + 'repository': fork_name} + self._compare_ok(id_, expected, given=response.body) + + fixture.destroy_repo(fork_name) + + def test_api_pull_error_no_remote_no_fork(self): + # should fail because no clone_uri is set id_, params = _build_data(self.apikey, 'pull', repoid=self.REPO, ) response = api_call(self, params)