Пример #1
0
def test_hub_list_keywords(mocker):
    mocker.return_value.__enter__.return_value.read.return_value = json.dumps(
        [{
            'name': 'foo'
        }, {
            'name': 'bar'
        }])

    args = set_hub_list_parser().parse_args(['--keywords', 'numeric'])
    response = HubIO(args).list()
    numeric_count = len(response)

    mocker.assert_called_once()
    assert numeric_count > 1

    args = set_hub_list_parser().parse_args(
        ['--keywords', 'numeric', 'randjojd'])
    response = HubIO(args).list()
    combined_count = len(response)

    assert mocker.call_count == 2
    assert combined_count > 1

    # Making sure both arguments are --keywords are considered as `either or`
    assert combined_count >= numeric_count
Пример #2
0
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
Пример #3
0
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(
        [os.path.join(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']
Пример #4
0
def test_hub_list_nonexisting_kind(mocker):
    mocker.return_value.__enter__.return_value.read.return_value = json.dumps([])

    args = set_hub_list_parser().parse_args(['--kind', 'blah'])
    response = HubIO(args).list()

    mocker.assert_called_once()
    assert not response
Пример #5
0
def test_hub_list_non_existing_kind():
    args = set_hub_list_parser().parse_args(['--kind', 'does-not-exist'])
    response = HubIO(args).list()
    assert not response
Пример #6
0
def test_hub_list():
    args = set_hub_list_parser().parse_args(['--keywords', 'numeric'])
    response = HubIO(args).list()
    assert len(response) > 0
Пример #7
0
def test_hub_list_local_with_submodule():
    args = set_hub_list_parser().parse_args(['--local-only'])
    response = HubIO(args).list()
    assert len(response) > 1