Skip to content

Devmsk #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/onapsdk/sdc/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, name: str = None, version: str = None, sdc_values: Dict[str,
inputs: List[Union[Property, NestedInput]] = None,
instantiation_type: Optional[ServiceInstantiationType] = \
None,
category: str = None):
category: str = None, role: str = "", function: str = "", service_type: str = ""):
"""
Initialize service object.

Expand All @@ -143,13 +143,17 @@ def __init__(self, name: str = None, version: str = None, sdc_values: Dict[str,
instantiation_type (ServiceInstantiationType, optional): service instantiation
type. ServiceInstantiationType.A_LA_CARTE by default
category (str, optional): service category name
role (str, optional): service role

"""
super().__init__(sdc_values=sdc_values, version=version, properties=properties,
inputs=inputs, category=category)
self.name: str = name or "ONAP-test-Service"
self.distribution_status = None
self.category_name: str = category
self.role: str = role
self.function: str = function
self.service_type: str = service_type
if sdc_values:
self.distribution_status = sdc_values['distributionStatus']
self.category_name = sdc_values["category"]
Expand Down Expand Up @@ -516,7 +520,8 @@ def create(self) -> None:
self._create("service_create.json.j2",
name=self.name,
instantiation_type=self.instantiation_type.value,
category=self.category)
category=self.category,
role=self.role, service_type=self.service_type, function=self.function)

def declare_resources_and_properties(self) -> None:
"""Delcare resources and properties.
Expand Down Expand Up @@ -688,6 +693,7 @@ def _specific_copy(self, obj: 'Service') -> None:
"""
super()._specific_copy(obj)
self.category_name = obj.category_name
self.role = obj.role

def _verify_distribute_to_sdc(self, desired_status: str,
desired_action: str, **kwargs) -> None:
Expand Down
5 changes: 4 additions & 1 deletion src/onapsdk/sdc/templates/service_create.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
"instantiationType": "{{ instantiation_type }}",
"environmentContext": "General_Revenue-Bearing",
{% include "sdc_resource_category.json.j2" %},
"icon": "network_l_1-3"
"icon": "network_l_1-3",
"serviceFunction": "{{ function }}",
"serviceRole": "{{ role }}",
"serviceType": "{{ service_type }}"
}
12 changes: 10 additions & 2 deletions tests/test_service.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,22 @@ def test_create(mock_exists, mock_category, mock_create):
mock_create.assert_called_once_with("service_create.json.j2",
name="ONAP-test-Service",
instantiation_type="A-la-carte",
category=svc.category)
category=svc.category,
role="",
function="",
service_type=""
)
mock_create.reset_mock()
svc = Service(instantiation_type=ServiceInstantiationType.MACRO)
svc.create()
mock_create.assert_called_once_with("service_create.json.j2",
name="ONAP-test-Service",
instantiation_type="Macro",
category=svc.category)
category=svc.category,
role="",
function="",
service_type=""
)

@mock.patch.object(Service, 'exists')
@mock.patch.object(Service, 'send_message')
Expand Down