Skip to content

Commit

Permalink
Fixed unit test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nabhajit-ray committed Mar 2, 2021
1 parent 1f3dde0 commit 4293d3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 5 additions & 7 deletions library/oneview_appliance_device_snmp_v3_users_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ def __init__(self):
self.set_resource_object(self.oneview_client.appliance_device_snmp_v3_users)

def execute_module(self):
if self.module.params['username']:
obj_appliance_device_snmp_v3_users = self.resource_client.get_by_name(self.module.params['username'])
appliance_device_snmp_v3_users = obj_appliance_device_snmp_v3_users.data if obj_appliance_device_snmp_v3_users else None
elif self.module.params['uri']:
obj_appliance_device_snmp_v3_users = self.resource_client.get_by_uri(self.module.params['uri'])
appliance_device_snmp_v3_users = obj_appliance_device_snmp_v3_users.data if obj_appliance_device_snmp_v3_users else None
else:
appliance_device_snmp_v3_users = []

if self.current_resource:
appliance_device_snmp_v3_users = self.current_resource.data
elif not self.module.params.get("name") and not self.module.params.get('uri'):
appliance_device_snmp_v3_users = self.resource_client.get_all(**self.facts_params)

return dict(changed=False, ansible_facts=dict(appliance_device_snmp_v3_users=appliance_device_snmp_v3_users))
Expand Down
9 changes: 5 additions & 4 deletions test/test_oneview_appliance_device_snmp_v3_users_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
config='config.json'
)

PARAMS_GET_BY_ID = dict(
PARAMS_GET_BY_NAME = dict(
config='config.json',
id='3953867c-5283-4059-a9ae-33487f901e85'
name='TestUser1'
)

PRESENT_CONFIGURATION = [{
Expand Down Expand Up @@ -68,8 +68,9 @@ def test_should_get_all_snmp_v3_users(self):
)

def test_should_get_by_id_snmp_v3_users(self):
self.resource.get_by_id.return_value = PRESENT_CONFIGURATION
self.mock_ansible_module.params = PARAMS_GET_BY_ID
self.resource.data = PRESENT_CONFIGURATION
self.resource.get_by_name.return_value = self.resource
self.mock_ansible_module.params = PARAMS_GET_BY_NAME

ApplianceDeviceSnmpV3UsersFactsModule().run()

Expand Down

0 comments on commit 4293d3b

Please sign in to comment.