def test_slave_param_overrides_when_get_project_from_master_is_disabled(self): Configuration['get_project_from_master'] = False git = Git(url='http://original-user-specified-url.test/repo-path/repo-name') actual_overrides = git.slave_param_overrides() self.assertFalse( 'url' in actual_overrides, '"url" should not be in the params to override when "get_project_from_master" is False', ) self.assertFalse( 'branch' in actual_overrides, '"branch" should not be in the params to override when "get_project_from_master" is False', )
def test_slave_param_overrides_returns_expected(self): self._patch_popen({ 'git rev-parse FETCH_HEAD': _FakePopenResult(stdout='deadbee123\n') }) Configuration['repo_directory'] = '/repo-directory' git = Git(url='http://original-user-specified-url.test/repo-path/repo-name') git.fetch_project() actual_overrides = git.slave_param_overrides() expected_overrides = { 'url': 'ssh://fake_hostname/repodirectory/originaluserspecifiedurl.test/repopath/reponame', 'branch': 'refs/clusterrunner/deadbee123', } self.assertEqual(expected_overrides, actual_overrides, 'Slave param overrides from Git object should match' 'expected.')
def test_slave_param_overrides_returns_expected(self): Configuration['get_project_from_master'] = True Configuration['repo_directory'] = '/repo-directory' self._patch_popen({ 'git rev-parse FETCH_HEAD': _FakePopenResult(stdout='deadbee123\n') }) git = Git(url='http://original-user-specified-url.test/repo-path/repo-name') git.fetch_project() actual_overrides = git.slave_param_overrides() expected_overrides = { 'url': 'ssh://fake_hostname/repodirectory/originaluserspecifiedurl.test/repopath/reponame', 'branch': 'refs/clusterrunner/deadbee123', } self.assertEqual(expected_overrides, actual_overrides, 'Slave param overrides from Git object should match' 'expected.')
def test_slave_param_overrides_returns_expected(self): self._patch_popen({ 'git rev-parse FETCH_HEAD': _FakePopenResult(stdout='deadbee123\n') }) self.patch('app.project_type.git.os.path.exists').return_value = False self.patch('app.project_type.git.os.path.isfile').return_value = False self.patch('app.project_type.git._GitRemoteCommandExecutor') Configuration['repo_directory'] = '/repo-directory' git = Git( url='http://original-user-specified-url.test/repo-path/repo-name') git.fetch_project() actual_overrides = git.slave_param_overrides() expected_overrides = { 'url': 'ssh://fake_hostname/repodirectory/originaluserspecifiedurl.test/repopath/reponame', 'branch': 'refs/clusterrunner/deadbee123', } self.assertEqual( expected_overrides, actual_overrides, 'Slave param overrides from Git object should match' 'expected.')