def test_hub_list_keywords(): args = set_hub_list_parser().parse_args(['--keywords', 'numeric']) response = HubIO(args).list() numeric_count = len(response) assert numeric_count > 1 args = set_hub_list_parser().parse_args( ['--keywords', 'numeric', 'randjojd']) response = HubIO(args).list() combined_count = len(response) assert combined_count > 1 # Making sure both arguments are --keywords are considered as `either or` assert combined_count >= numeric_count
def test_hub_build_push(monkeypatch, mocker): monkeypatch.setattr(Path, 'is_file', True) mock_access_token = mocker.patch.object(hubapi, '_fetch_access_token', autospec=True) mock_access_token.return_value = os.environ.get('GITHUB_TOKEN', None) args = set_hub_build_parser().parse_args( [str(cur_dir + '/hub-mwu'), '--push', '--host-info']) summary = HubIO(args).build() with open(cur_dir + '/hub-mwu' + '/manifest.yml') as fp: manifest_jaml = JAML.load(fp, substitute=True) manifest = expand_dict(manifest_jaml) assert summary['is_build_success'] assert manifest['version'] == summary['version'] assert manifest['description'] == summary['manifest_info']['description'] assert manifest['author'] == summary['manifest_info']['author'] assert manifest['kind'] == summary['manifest_info']['kind'] assert manifest['type'] == summary['manifest_info']['type'] assert manifest['vendor'] == summary['manifest_info']['vendor'] assert manifest['keywords'] == summary['manifest_info']['keywords'] args = set_hub_list_parser().parse_args([ '--name', summary['manifest_info']['name'], '--keywords', summary['manifest_info']['keywords'][0], '--type', summary['manifest_info']['type'] ]) response = HubIO(args).list() manifests = response assert len(manifests) >= 1 assert manifests[0]['name'] == summary['manifest_info']['name']
def test_hub_build_push(): args = set_hub_build_parser().parse_args( [os.path.join(cur_dir, 'hub-mwu'), '--push', '--host-info']) summary = HubIO(args).build() with open(os.path.join(cur_dir, 'hub-mwu', 'manifest.yml')) as fp: manifest = yaml.load(fp) assert summary['is_build_success'] assert manifest['version'] == summary['version'] assert manifest['description'] == summary['manifest_info']['description'] assert manifest['author'] == summary['manifest_info']['author'] assert manifest['kind'] == summary['manifest_info']['kind'] assert manifest['type'] == summary['manifest_info']['type'] assert manifest['vendor'] == summary['manifest_info']['vendor'] assert manifest['keywords'] == summary['manifest_info']['keywords'] args = set_hub_list_parser().parse_args([ '--name', summary['manifest_info']['name'], '--keywords', summary['manifest_info']['keywords'][0], '--type', summary['manifest_info']['type'] ]) response = HubIO(args).list() manifests = response.json()['manifest'] assert response.status_code == 200 assert len(manifests) >= 1 assert manifests[0]['name'] == summary['manifest_info']['name']
def test_hub_build_push_push_again(): args = set_hub_build_parser().parse_args([str(cur_dir / 'hub-mwu'), '--push', '--host-info']) summary = HubIO(args).build() with open(cur_dir / 'hub-mwu' / 'manifest.yml') as fp: manifest = JAML.load(fp) assert summary['is_build_success'] assert manifest['version'] == summary['version'] assert manifest['description'] == summary['manifest_info']['description'] assert manifest['author'] == summary['manifest_info']['author'] assert manifest['kind'] == summary['manifest_info']['kind'] assert manifest['type'] == summary['manifest_info']['type'] assert manifest['vendor'] == summary['manifest_info']['vendor'] assert manifest['keywords'] == summary['manifest_info']['keywords'] args = set_hub_list_parser().parse_args([ '--name', summary['manifest_info']['name'], '--keywords', summary['manifest_info']['keywords'][0], '--type', summary['manifest_info']['type'] ]) response = HubIO(args).list() manifests = response assert len(manifests) >= 1 assert manifests[0]['name'] == summary['manifest_info']['name'] with pytest.raises(ImageAlreadyExists): # try and push same version again should fail with `--no-overwrite` args = set_hub_build_parser().parse_args([str(cur_dir / 'hub-mwu'), '--push', '--host-info', '--no-overwrite']) HubIO(args).build()
def test_hub_build_push(): args = set_hub_build_parser().parse_args([str(cur_dir / 'hub-mwu'), '--push', '--host-info']) summary = HubIO(args).build() with open(cur_dir / 'hub-mwu' / 'manifest.yml') as fp: manifest = JAML.load(fp) assert summary['is_build_success'] assert manifest['version'] == summary['version'] assert manifest['description'] == summary['manifest_info']['description'] assert manifest['author'] == summary['manifest_info']['author'] assert manifest['kind'] == summary['manifest_info']['kind'] assert manifest['type'] == summary['manifest_info']['type'] assert manifest['vendor'] == summary['manifest_info']['vendor'] assert manifest['keywords'] == summary['manifest_info']['keywords'] args = set_hub_list_parser().parse_args([ '--name', summary['manifest_info']['name'], '--keywords', summary['manifest_info']['keywords'][0], '--type', summary['manifest_info']['type'] ]) response = HubIO(args).list() manifests = response assert len(manifests) >= 1 assert manifests[0]['name'] == summary['manifest_info']['name']
def test_hub_build_push_push_again(monkeypatch, access_token_github): monkeypatch.setattr(Path, 'is_file', True) monkeypatch.setattr(hubapi, '_fetch_access_token', access_token_github) args = set_hub_build_parser().parse_args( [str(cur_dir) + '/hub-mwu', '--push', '--host-info']) summary = HubIO(args).build() with open(str(cur_dir) + '/hub-mwu' + '/manifest.yml') as fp: manifest_jaml = JAML.load(fp, substitute=True) manifest = expand_dict(manifest_jaml) assert summary['is_build_success'] assert manifest['version'] == summary['version'] assert manifest['description'] == summary['manifest_info']['description'] assert manifest['author'] == summary['manifest_info']['author'] assert manifest['kind'] == summary['manifest_info']['kind'] assert manifest['type'] == summary['manifest_info']['type'] assert manifest['vendor'] == summary['manifest_info']['vendor'] assert manifest['keywords'] == summary['manifest_info']['keywords'] args = set_hub_list_parser().parse_args([ '--name', summary['manifest_info']['name'], '--keywords', summary['manifest_info']['keywords'][0], '--type', summary['manifest_info']['type'] ]) response = HubIO(args).list() manifests = response assert len(manifests) >= 1 assert manifests[0]['name'] == summary['manifest_info']['name'] with pytest.raises(ImageAlreadyExists): # try and push same version again should fail with `--no-overwrite` args = set_hub_build_parser().parse_args([ str(cur_dir) + '/hub-mwu', '--push', '--host-info', '--no-overwrite' ]) HubIO(args).build()
def test_hub_list_nonexisting_kind(): args = set_hub_list_parser().parse_args(['--kind', 'blah']) response = HubIO(args).list() assert response.status_code == 400 assert response.text.lower() == 'no docs found'
def test_hub_list_local_with_submodule(): args = set_hub_list_parser().parse_args(['--local-only']) response = HubIO(args).list() assert len(response) > 1
def test_hub_list_nonexisting_kind(): args = set_hub_list_parser().parse_args(['--kind', 'blah']) response = HubIO(args).list() assert not response