aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-14 07:59:00 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-15 15:26:29 +0000
commitc68b629f457fe00387075ed260b6d0a5c0bb45a0 (patch)
tree89d7f3bb9e7027d4db128487ed0f9a5dcac61137 /test
parenta958b986af7b8f17ad23e5c31c7ff719c153021e (diff)
Add unit tests for provisioning management service
This adds pytest based unit tests for the service provider. Testing PUT and GET requests is covered within this patch. Change-Id: Id9bcb870b032c6fce64985a5fd501bbd44031f50 Issue-ID: INT-1529 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test')
-rw-r--r--test/mocks/prov-mns-provider/src/test_mns.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/mocks/prov-mns-provider/src/test_mns.py b/test/mocks/prov-mns-provider/src/test_mns.py
new file mode 100644
index 000000000..1ae88e8ce
--- /dev/null
+++ b/test/mocks/prov-mns-provider/src/test_mns.py
@@ -0,0 +1,49 @@
+import requests
+from uuid import uuid4
+import ProvMnSProvider
+import logging
+from json import dumps
+
+logging.basicConfig(level=logging.DEBUG)
+logger = logging.getLogger(__name__)
+
+MOI_ID = str(uuid4())
+MOI_CLASS = ProvMnSProvider.Cretaed_MOIs_list[0]['class']
+MOI_DATA_TMPL = { 'data': ProvMnSProvider.Cretaed_MOIs_list[0] }
+URI_SCHEMA = 'http'
+AUTH_STRING = (ProvMnSProvider.username, ProvMnSProvider.password)
+URI_BASE_STRING = URI_SCHEMA + '://' + ProvMnSProvider.ipAddress + ':' + \
+ str(ProvMnSProvider.portNumber) + ProvMnSProvider.prefix + \
+ '/' + MOI_CLASS + '/' + MOI_ID
+URI_PUT_STRING = URI_BASE_STRING
+URI_GET_STRING = URI_BASE_STRING + '?scope=BASE_ONLY&filter=' + MOI_CLASS + \
+ '&fields=gNBId&fields=gNBIdLength'
+URI_PATCH_STRING = URI_BASE_STRING + '?scope=BASE_ONLY&filter=' + MOI_CLASS
+URI_DELETE_STRING = URI_PATCH_STRING
+
+def test_put():
+ '''Validate PUT request'''
+
+ MOI_DATA = MOI_DATA_TMPL
+ MOI_DATA['data']['id'] = MOI_ID
+ MOI_DATA['data']['href'] = '/' + MOI_CLASS + '/' + MOI_ID
+ req_put = requests.put('{0}'.format(URI_PUT_STRING), auth=AUTH_STRING,
+ json=MOI_DATA)
+
+ if req_put.status_code != requests.codes.created:
+ logger.error('PUT request to {0} failed'.format(URI_PUT_STRING))
+ logger.debug('MOI data payload: {0}'.format(dumps(MOI_DATA,indent=2)))
+ logger.debug('Response content: {0}'.format(req_put.text))
+
+ assert req_put.status_code == requests.codes.created
+
+def test_get():
+ '''Validate GET request'''
+
+ req_get = requests.get('{0}'.format(URI_GET_STRING), auth=AUTH_STRING)
+
+ if req_get.status_code != requests.codes.ok:
+ logger.error('GET request to {0} failed'.format(URI_GET_STRING))
+ logger.debug('Response content: {0}'.format(req_get.text))
+
+ assert req_get.status_code == requests.codes.ok