From 766bfb57f822b15cb1bf44bbdf250733ff2ea7d2 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Thu, 12 Dec 2019 20:40:23 +0100
Subject: [PATCH] forgot to actually test the api in 2nd method

---
 test/test_opsdb_queries.py | 47 ++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/test/test_opsdb_queries.py b/test/test_opsdb_queries.py
index 1282def5..a268ccb7 100644
--- a/test/test_opsdb_queries.py
+++ b/test/test_opsdb_queries.py
@@ -167,34 +167,34 @@ def test_coriant_path(connection, equipment, card, port):
     jsonschema.validate(circuit, CORIANT_PATH_METADATA)
 
 
-def test_get_service_users(connection):
-    schema = {
-        '$schema': 'http://json-schema.org/draft-07/schema#',
-
-        'definitions': {
-            'service-user': {
-                'type': 'object',
-                'properties': {
-                    'service_id': {'type': 'integer'},
-                    'user': {'type': 'string'}
-                },
-                'required': ['service_id', 'user'],
-                'additionalProperties': False
-            }
-        },
+SERVICE_USER_LIST_SCHEMA = {
+    '$schema': 'http://json-schema.org/draft-07/schema#',
+
+    'definitions': {
+        'service-user': {
+            'type': 'object',
+            'properties': {
+                'service_id': {'type': 'integer'},
+                'user': {'type': 'string'}
+            },
+            'required': ['service_id', 'user'],
+            'additionalProperties': False
+        }
+    },
 
-        'type': 'array',
-        'items': {'$ref': '#/definitions/service-user'}
-    }
+    'type': 'array',
+    'items': {'$ref': '#/definitions/service-user'}
+}
 
+
+def test_get_service_users(connection):
     service_id_list = [47673, 47675]
     users = opsdb.get_service_users(connection, service_id_list)
     users = list(users)
-    jsonschema.validate(users, schema)
+    jsonschema.validate(users, SERVICE_USER_LIST_SCHEMA)
     assert users
 
 
-
 def test_get_all_service_users(connection, cached_test_data):
 
     def _all_interfaces():
@@ -218,8 +218,11 @@ def test_get_all_service_users(connection, cached_test_data):
 
     ids = {s['service_id'] for s in _all_service_ids(_all_interfaces())}
     assert len(ids) > 0
-    #
-    # services = {}
+
+    service_users = list(opsdb.get_service_users(connection, list(ids)))
+    jsonschema.validate(service_users, SERVICE_USER_LIST_SCHEMA)
+    assert service_users
+
     # for user in opsdb.get_service_users(connection, list(ids)):
     #     services.setdefault(user['service_id'], []).append(user['user'])
     #
-- 
GitLab