summaryrefslogtreecommitdiff
path: root/test/test_api.py
blob: 20787d437f9cad723449323266c70815610289fe (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
from obsapi import ObsApi
from lxml import etree

api = ObsApi(apiurl='https://api.suse.com')

prj = 'Test:obsapi'
pkg = 'suse-hello-1.0'
repo = 'SLE_12'
arch = 'x86_64'


def test_get_package_meta():
    try:
        response = etree.fromstring(api.get_package_meta(prj=prj, pkg=pkg))
    except:
        response = {}
    assert response.get('name', None) == 'suse-hello-1.0'


def test_ls_prj():
    assert api.ls(prj=prj) == ['suse-hello-1.0']


def test_ls_pkg():
    files = ['COPYING', 'suse-hello-1.0.tar.bz2',
             'suse-hello.changes', 'suse-hello.spec',
             ]
    directory, listing = api.ls(prj=prj, pkg=pkg)
    assert directory.name == 'suse-hello-1.0'
    items = [i.name for i in listing]
    for f in files:
        assert f in items


def test_get_binaries():
    files = ['_statistics', 'rpmlint.log', 'suse-hello-1.0-2.1.src.rpm',
             'suse-hello-kmp-default-1.0_k3.12.28_4-2.1.x86_64.rpm',
             ]
    listing = api.get_binaries(prj=prj, pkg=pkg, repo=repo, arch=arch)
    items = [i.filename for i in listing]
    for f in files:
        assert f in items


def test_get_vendor():
    assert api.get_vendor(prj=prj) == u'Test:obsapi'