Esempio n. 1
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']
Esempio n. 2
0
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()
Esempio n. 3
0
 def test_yaml_expand3(self):
     with open('yaml/test-expand3.yml') as fp:
         a = yaml.load(fp)
     b = expand_dict(a)
     print(b)
Esempio n. 4
0
 def test_yaml_expand3(self):
     with open(os.path.join(cur_dir, 'yaml/test-expand3.yml')) as fp:
         a = yaml.load(fp)
     b = expand_dict(a)
     print(b)
Esempio n. 5
0
def test_yaml_expand3():
    with open(os.path.join(cur_dir, 'yaml/test-expand3.yml')) as fp:
        a = yaml.load(fp)
    b = expand_dict(a)
    assert b['pea_workspace'] != '{root.workspace}/{root.name}-{this.pea_id}'
Esempio n. 6
0
def test_yaml_expand3():
    with open(os.path.join(cur_dir, 'yaml/test-expand3.yml')) as fp:
        a = JAML.load(fp)

    b = expand_dict(a)
    assert b['max_snapshot'] == 0