def test_surch_repo_command_with_arguments_without_string_opt(self): self.args = 'https://github.com/cloudify-cosmo/surch.git' opts = { '-p': test_path, '-l': test_path, '-v': None} result = _invoke_click('surch_repo', [self.args], opts) self.assertEqual(1, result.exit_code) utils.remove_repos_folder(test_path)
def test_surch_repo_command_with_config_and_found_results(self): config_file_path = os.path.join(path, 'config/repo-config.yaml') self.args = ' ' opts = {'-c': config_file_path, '-v': None} _invoke_click('surch_repo', [self.args], opts) result_path = os.path.join(constants.RESULTS_PATH, 'cloudify-cosmo/results.json') dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) utils.remove_repos_folder(constants.DEFAULT_PATH)
def test_get_all_commits(self): repo_class = repo.Repo( repo_url='https://github.com/cloudify-cosmo/surch.git', search_list=['a', 'b', 'c']) repo_class._clone_or_pull() repo_path = os.path.join(constants.CLONED_REPOS_PATH, 'surch') if not os.path.isdir(repo_path): repo_class._clone_or_pull() commits = repo_class._get_all_commits() self.assertTrue(commits > 0) utils.remove_repos_folder(constants.DEFAULT_PATH)
def test_surch_repo_command_with_config_and_found_results(self): config_file_path = os.path.join(path, 'config/repo-config.yaml') self.args = ' ' opts = { '-c': config_file_path, '-v': None} _invoke_click('surch_repo', [self.args], opts) result_path = os.path.join(constants.RESULTS_PATH, 'cloudify-cosmo/results.json') dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) utils.remove_repos_folder(constants.DEFAULT_PATH)
def test_surch_user_command_with_config_no_auth_and_found_results(self): config_file_path = os.path.join(path, 'config/user-config_no_auth.yaml') self.args = ' ' opts = {'-c': config_file_path, '-v': None} _invoke_click('surch_user', [self.args], opts) result_path = os.path.join(constants.RESULTS_PATH, 'Havivw/results.json') dicts_num = count_dicts_in_results_file(result_path) success = dicts_num > 0 self.assertTrue(success) utils.remove_repos_folder(constants.DEFAULT_PATH)
def test_surch_repo_command_with_arguments_found_results_and_remove(self): result_path = os.path.join(test_path, 'results.json') repo_path = os.path.join(test_path, 'clones/surch') self.args = 'https://github.com/cloudify-cosmo/surch.git' opts = { '-s': 'import', '-p': os.path.join(test_path, 'clones'), '-l': test_path, '-R': None} _invoke_click('surch_repo', [self.args], opts) dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) self.assertFalse(os.path.isdir(repo_path)) utils.remove_repos_folder(test_path)
def test_surch_user_command_with_config_no_auth_and_found_results(self): config_file_path = os.path.join(path, 'config/user-config_no_auth.yaml') self.args = ' ' opts = { '-c': config_file_path, '-v': None} _invoke_click('surch_user', [self.args], opts) result_path = os.path.join(constants.RESULTS_PATH, 'Havivw/results.json') dicts_num = count_dicts_in_results_file(result_path) success = dicts_num > 0 self.assertTrue(success) utils.remove_repos_folder(constants.DEFAULT_PATH)
def test_surch_user_command_with_arguments_and_found_results(self): test_path = os.path.join(path, 'test/Havivw') result_path = os.path.join(path, 'test/Havivw/results.json') self.args = 'Havivw' opts = { '-s': 'import', '-p': test_path, '-l': test_path, '--include-repo=': 'surch', '-v': None} result = _invoke_click('surch_user', [self.args], opts) self.assertEqual(result.exit_code, 0) dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) utils.remove_repos_folder(test_path)
def test_surch_repo_command_with_arguments_found_results_and_remove(self): result_path = os.path.join(test_path, 'results.json') repo_path = os.path.join(test_path, 'clones/surch') self.args = 'https://github.com/cloudify-cosmo/surch.git' opts = { '-s': 'import', '-p': os.path.join(test_path, 'clones'), '-l': test_path, '-R': None } _invoke_click('surch_repo', [self.args], opts) dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) self.assertFalse(os.path.isdir(repo_path)) utils.remove_repos_folder(test_path)
def test_surch_user_command_with_arguments_and_found_results(self): test_path = os.path.join(path, 'test/Havivw') result_path = os.path.join(path, 'test/Havivw/results.json') self.args = 'Havivw' opts = { '-s': 'import', '-p': test_path, '-l': test_path, '--include-repo=': 'surch', '-v': None } result = _invoke_click('surch_user', [self.args], opts) self.assertEqual(result.exit_code, 0) dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) utils.remove_repos_folder(test_path)
def test_surch_org_command_with_arguments_and_found_results(self): self.args = 'cloudify-cosmo' opts = { '-s': 'import', '-p': os.path.join(test_path, 'cloudify-cosmo/clones'), '-l': os.path.join(test_path, 'cloudify-cosmo'), '--include-repo=': 'surch', '-v': None, '-R': None} result = _invoke_click('surch_org', [self.args], opts) result_path = os.path.join(test_path, 'cloudify-cosmo/results.json') self.assertEqual(result.exit_code, 0) dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) self.assertFalse(os.path.isdir( '{0}cloudify-cosmo/clones/surch'.format(test_path))) utils.remove_repos_folder(test_path)
def test_surch_org_command_with_arguments_and_found_results(self): self.args = 'cloudify-cosmo' opts = { '-s': 'import', '-p': os.path.join(test_path, 'cloudify-cosmo/clones'), '-l': os.path.join(test_path, 'cloudify-cosmo'), '--include-repo=': 'surch', '-v': None, '-R': None } result = _invoke_click('surch_org', [self.args], opts) result_path = os.path.join(test_path, 'cloudify-cosmo/results.json') self.assertEqual(result.exit_code, 0) dicts_num = count_dicts_in_results_file(result_path) self.assertTrue(dicts_num > 0) self.assertFalse( os.path.isdir('{0}cloudify-cosmo/clones/surch'.format(test_path))) utils.remove_repos_folder(test_path)
def test_remove_folder(self): if not os.path.isdir(test_path): os.makedirs(test_path) utils.remove_repos_folder(test_path) self.assertFalse(os.path.isdir(test_path))
def test_surch_repo_command_with_arguments_without_string_opt(self): self.args = 'https://github.com/cloudify-cosmo/surch.git' opts = {'-p': test_path, '-l': test_path, '-v': None} result = _invoke_click('surch_repo', [self.args], opts) self.assertEqual(1, result.exit_code) utils.remove_repos_folder(test_path)