summaryrefslogtreecommitdiff
path: root/test/test_obs_source_api.py
blob: a1707135faebd636d18cc1f749d665abb1d25029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from obsapi.sourceapi import ObsSourceApi


prj = 'home:sbahling:obsapi:test'
pkg = 'suse-hello-1.0'
repo = 'SLE_12_SP3'
arch = 'x86_64'

sourceapi = ObsSourceApi(apiurl='https://api.opensuse.org')


def test_source_get_prj():
    xml = sourceapi.get(prj)
    assert '<entry name="suse-hello-1.0"/>' in xml


def test_source_get_pkg():
    xml = sourceapi.get(prj, pkg)
    assert '<directory name="suse-hello-1.0"' in xml


def test_source_get_file():
    source_file = sourceapi.get(prj, pkg, 'COPYING')
    assert 'GNU GENERAL PUBLIC LICENSE' in source_file


def test_source_get_meta_prj():
    xml = sourceapi.get_meta(prj)
    assert '<project name="{}">'.format(prj) in xml


def test_source_get_meta_pkg():
    xml = sourceapi.get_meta(prj, pkg)
    assert '<package name="{}" project="{}">'.format(pkg, prj) in xml


def test_source_get_prj_attributes():
    xml = sourceapi.get_attribute(prj)
    assert '<attributes>' in xml


def test_source_get_prj_attribute():
    xml = sourceapi.get_attribute(prj, attribute='OBS:Screenshots')
    assert '<attributes>' in xml
    assert 'name="Screenshots"' in xml
    assert 'namespace="OBS"' in xml


def test_source_get_pkg_attributes():
    xml = sourceapi.get_attribute(prj, pkg)
    assert '<attributes>' in xml
    assert 'name="Screenshots"' in xml
    assert 'namespace="OBS"' in xml


def test_source_get_prj_config():
    config = sourceapi.get_config(prj)
    assert 'Macros:' in config


def test_source_get_prj_pubkey():
    pubkey = sourceapi.get_pubkey(prj)
    assert '-BEGIN PGP PUBLIC KEY BLOCK-' in pubkey


def test_source_get_history():
    xml = sourceapi.get_history(prj, pkg)
    assert '<revisionlist>' in xml