From 1efd8e333a51fb4348e35fc005ed9438ab0a4e23 Mon Sep 17 00:00:00 2001
From: vermeul <swen@ethz.ch>
Date: Fri, 23 Aug 2019 14:18:13 +0200
Subject: [PATCH] added more vocabulary tests

---
 pybis/src/python/tests/test_vocabulary.py | 31 ++++++++++++++++++-----
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/pybis/src/python/tests/test_vocabulary.py b/pybis/src/python/tests/test_vocabulary.py
index 6ab6145bbb5..ad999f2550c 100644
--- a/pybis/src/python/tests/test_vocabulary.py
+++ b/pybis/src/python/tests/test_vocabulary.py
@@ -8,11 +8,30 @@ import time
 
 def test_create_delete_vocabulay_terms(openbis_instance):
     o=openbis_instance 
-
-    terms = o.get_terms()
-    assert terms is not None
-    assert terms.df is not None
+    timestamp = time.strftime('%a_%y%m%d_%H%M%S').upper()
+    voc_code = 'test_voc_'+timestamp+"_"+str(random.randint(0,1000))
     
+    voc = o.new_vocabulary(
+        code = voc_code,
+        description = 'description of vocabulary',
+        urlTemplate = 'https://ethz.ch',
+        terms = [
+            { "code": 'term_code1', "label": "term_label1", "description": "term_description1"},
+            { "code": 'term_code2', "label": "term_label2", "description": "term_description2"},
+            { "code": 'term_code3', "label": "term_label3", "description": "term_description3"}
+        ]   
+    )
+    assert voc.registrationDate is None
+    voc.save()
+    assert voc is not None
+    assert voc.registrationDate is not None
+    
+    voc_exists = o.get_vocabulary(voc_code)
+    assert voc_exists is not None
+    assert voc_exists.code == voc_code.upper()
 
-
-
+    voc.delete('test on '+str(timestamp))
+    
+    with pytest.raises(ValueError):
+        voc_exists = o.get_vocabulary(voc_code)
+        assert 1 == 0
-- 
GitLab