summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_obs_source_api.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/test_obs_source_api.py b/test/test_obs_source_api.py
new file mode 100644
index 0000000..205e344
--- /dev/null
+++ b/test/test_obs_source_api.py
@@ -0,0 +1,68 @@
+from obsapi.sourceapi import ObsSourceApi
+
+
+prj = 'Test:obsapi'
+pkg = 'suse-hello-1.0'
+repo = 'SLE_12'
+arch = 'x86_64'
+
+sourceapi = ObsSourceApi(apiurl='https://api.suse.com')
+
+
+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:MaintenanceIdTemplate')
+ assert '<attributes>' in xml
+ assert 'name="MaintenanceIdTemplate"' 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