Commit ba7158ba authored by Spiros Koulouzis's avatar Spiros Koulouzis

wrote tests

parent ad992d3a
......@@ -153,8 +153,7 @@ def get_node_requirements(id, node_name): # noqa: E501
def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None,
has_attributes=None, has_requirements=None, has_capabilities=None, has_artifacts=None,
derived_from=None): # noqa: E501
has_attributes=None, has_requirements=None, has_capabilities=None, has_artifacts=None): # noqa: E501
"""get_node_templates
returns nodes templates in topology # noqa: E501
......@@ -185,8 +184,7 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
res = tosca_template_service.get_node_templates(id, type_name=type_name, node_name=node_name,
has_interfaces=has_interfaces, has_properties=has_properties,
has_attributes=has_attributes, has_requirements=has_requirements,
has_capabilities=has_capabilities, has_artifacts=has_artifacts,
derived_from=derived_from)
has_capabilities=has_capabilities, has_artifacts=has_artifacts)
if res:
return res
return 'Not Found', 404
......
......@@ -117,7 +117,7 @@ def get_interface_types(id, interface_type=None):
def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None,
has_attributes=None,
has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None):
has_requirements=None, has_capabilities=None, has_artifacts=None):
if len(node_template_db) <= 1:
tosca_template_model = get_tosca_template_model_by_id(id)
object_list = tosca_template_model.topology_template.node_templates
......@@ -147,9 +147,6 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
if type_name:
query = Query()
queries.append(query.type == type_name)
if derived_from:
query = Query()
queries.append(query.derived_from == derived_from)
if has_properties:
query = Query()
prop = None
......
......@@ -161,7 +161,7 @@ paths:
type: "boolean"
- name: "type_name"
in: "query"
description: "The relationship type"
description: "The type_name"
required: false
type: "string"
- name: "has_properties"
......@@ -321,11 +321,6 @@ paths:
description: "filter if has artifacts"
required: false
type: "boolean"
- name: "derived_from"
in: "query"
description: "derived from"
required: false
type: "string"
responses:
200:
description: "successful operation"
......@@ -582,7 +577,7 @@ paths:
200:
description: "successful operation"
schema:
$ref: "#/definitions/NodeTemplate"
type: "string"
404:
description: "Not found"
405:
......@@ -610,6 +605,8 @@ paths:
200:
description: "successful operation"
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
......@@ -717,7 +714,8 @@ definitions:
policy_types:
type: "object"
additionalProperties:
type: "string"
type: "object"
properties: {}
group_types:
type: "object"
additionalProperties:
......@@ -732,16 +730,14 @@ definitions:
node_types:
key: "{}"
policy_types:
key: "policy_types"
key: "{}"
topology_template:
outputs:
- key: "{}"
- key: "{}"
key: "{}"
substitution_mappings:
key: "{}"
inputs:
- key: "{}"
- key: "{}"
key: "inputs"
node_templates:
key:
requirements:
......@@ -804,12 +800,9 @@ definitions:
description:
type: "string"
inputs:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
type: "string"
node_templates:
type: "object"
additionalProperties:
......@@ -820,8 +813,6 @@ definitions:
type: "object"
properties: {}
outputs:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
......@@ -845,13 +836,11 @@ definitions:
properties: {}
example:
outputs:
- key: "{}"
- key: "{}"
key: "{}"
substitution_mappings:
key: "{}"
inputs:
- key: "{}"
- key: "{}"
key: "inputs"
node_templates:
key:
requirements:
......
......@@ -59,194 +59,264 @@ class TestDefaultController(BaseTestCase):
self.assertTrue(response.is_json)
self.assertIsInstance(response.json, list)
# def test_get_dsl_definitions(self):
# """Test case for get_dsl_definitions
#
#
# """
# # query_string = [('anchors', 'anchors_example'), ('derived_from', 'derived_from_example')]
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/dsl_definitions'.format(id='id_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_imports(self):
# """Test case for get_imports
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/imports'.format(id='id_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_node_outputs(self):
# """Test case for get_node_outputs
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs'.format(
# id='id_example', node_name='node_name_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_node_properties(self):
# """Test case for get_node_properties
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(
# id='id_example', node_name='node_name_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_node_requirements(self):
# """Test case for get_node_requirements
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements'.format(
# id='id_example', node_name='node_name_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_node_templates(self):
# """Test case for get_node_templates
#
#
# """
# query_string = [('type_name', 'type_name_example'),
# ('node_name', 'node_name_example'),
# ('has_interfaces', True),
# ('has_properties', True),
# ('has_attributes', True),
# ('has_requirements', True),
# ('has_capabilities', True),
# ('has_artifacts', True),
# ('derived_from', 'derived_from_example')]
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id='id_example'),
# method='GET',
# query_string=query_string)
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_node_type_name(self):
# """Test case for get_node_type_name
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name'.format(
# id='id_example', node_name='node_name_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_parent_type_name(self):
# """Test case for get_parent_type_name
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from'.format(
# id='id_example', node_name='node_name_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_related_nodes(self):
# """Test case for get_related_nodes
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/related'.format(
# id='id_example', node_name='node_name_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_relationship_templates(self):
# """Test case for get_relationship_templates
#
#
# """
# query_string = [('type_name', 'type_name_example'),
# ('derived_from', 'derived_from_example')]
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/relationship_templates'.format(id='id_example'),
# method='GET',
# query_string=query_string)
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_topology_template(self):
# """Test case for get_topology_template
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template'.format(id='id_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_tosca_template(self):
# """Test case for get_tosca_template
#
#
# """
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}'.format(id='id_example'),
# method='GET')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_get_types(self):
# """Test case for get_types
#
#
# """
# query_string = [('kind_of_type', 'kind_of_type_example'),
# ('has_interfaces', True),
# ('type_name', 'type_name_example'),
# ('has_properties', True),
# ('has_attributes', True),
# ('has_requirements', True),
# ('has_capabilities', True),
# ('has_artifacts', True),
# ('derived_from', 'derived_from_example')]
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/types'.format(id='id_example'),
# method='GET',
# query_string=query_string)
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
# def test_set_node_properties(self):
# """Test case for set_node_properties
#
#
# """
# properties = None
# response = self.client.open(
# '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(
# id='id_example', node_name='node_name_example'),
# method='PUT',
# data=json.dumps(properties),
# content_type='application/json')
# self.assert200(response,
# 'Response body is : ' + response.data.decode('utf-8'))
#
def test_get_dsl_definitions(self):
"""Test case for get_dsl_definitions
"""
# query_string = [('anchors', 'anchors_example'), ('derived_from', 'derived_from_example')]
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/dsl_definitions'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
def test_get_imports(self):
"""Test case for get_imports
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/imports'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
def test_get_node_outputs(self):
"""Test case for get_node_outputs
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_node_properties(self):
"""Test case for get_node_properties
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_node_requirements(self):
"""Test case for get_node_requirements
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements'.format(
id=id_example, node_name='kubernetes'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_get_node_templates(self):
"""Test case for get_node_templates
"""
id_example = self.upload_file()
query_string = [('type_name', None),
('node_name', 'compute'),
('has_interfaces', True),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
query_string = [('type_name', None),
('node_name', None),
('has_interfaces', None),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
query_string = [('type_name', 'tosca.nodes.ARTICONF.Container.Application.Docker'),
('node_name', None),
('has_interfaces', None),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_get_node_type_name(self):
"""Test case for get_node_type_name
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, str)
def test_get_parent_type_name(self):
"""Test case for get_parent_type_name
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from'.format(
id=id_example, node_name='kubernetes'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, str)
def test_get_related_nodes(self):
"""Test case for get_related_nodes
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/related'.format(
id=id_example, node_name='mysql'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_get_relationship_templates(self):
"""Test case for get_relationship_templates
"""
id_example = self.upload_file()
query_string = [('type_name', None),
('derived_from', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/relationship_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
def test_get_topology_template(self):
"""Test case for get_topology_template
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_tosca_template(self):
"""Test case for get_tosca_template
"""
id_example = self.upload_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_types(self):
"""Test case for get_types
"""
id_example = self.upload_file()
query_string = [('kind_of_type', 'interface_types'),
('has_interfaces', None),
('type_name', 'tosca.interfaces.ARTICONF.CloudsStorm'),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None),
('derived_from', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/types'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
query_string = [('kind_of_type', 'interface_types'),
('has_interfaces', None),
('type_name', None),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None),
('derived_from', 'tosca.interfaces.node.lifecycle.Standard')]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/types'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_set_node_properties(self):
"""Test case for set_node_properties
"""
id_example = self.upload_file()
properties = {'properties': {'cpu_frequency': '2 GHz'}}
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(
id=id_example, node_name='compute'),
method='PUT',
data=json.dumps(properties),
content_type='application/json')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
# def test_upload_tosca_template(self):
# """Test case for upload_tosca_template
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment