def test_resolve_item_url_github(self): "Test resolution of a component url" ocf = OpenControlFiles() repo_ref = 'https://github.com/18F/cg-compliance' revision = 'master' item_type = "components" component_path = './CloudCheckr' # repo_url, revision, path, yaml_file = 'component.yaml' correct_url = ocf.resolve_item_url(repo_ref, revision, component_path, item_type) self.assertTrue( 'https://raw.githubusercontent.com/18F/cg-compliance/master/./CloudCheckr/component.yaml' == correct_url)
def test_resolve_item_url_localfile(self): "Test resolution of a component url that is a localfile" ocf = OpenControlFiles() # construct absolute file path dir_path = os.path.dirname(os.path.realpath(__file__)) repo_ref = "file://{}/{}".format(dir_path, "test_data/repo1") print("dir_path is {}".format(dir_path)) print("repo_ref is {}".format(repo_ref)) revision = 'master' component_path = './AU_policy' item_type = "components" resolved_url = ocf.resolve_item_url(repo_ref, revision, component_path, item_type) expected_url = "{}/{}/{}".format(repo_ref, component_path, 'component.yaml') print("expected_url is {}".format(expected_url)) print("resolved_url is {}".format(resolved_url)) self.assertTrue(expected_url == resolved_url)