def test_should_fail_update_vlan_range_when_fabric_not_found(self): self.resource.get_by.return_value = [] self.resource.update_reserved_vlan_range.return_value = PRESENT_FABRIC_VLAN_RANGE self.mock_ansible_module.params = FABRIC_PARAMS FabricModule().run() self.mock_ansible_module.fail_json.assert_called_once_with(exception=mock.ANY, msg=FabricModule.MSG_NOT_FOUND)
def test_should_not_update_when_data_is_equals(self): # Mock OneView resource functions self.resource.get_by.return_value = [self.PRESENT_FABRIC_VLAN_RANGE] self.resource.update_reserved_vlan_range.return_value = self.PRESENT_FABRIC_VLAN_RANGE # Mock Ansible params self.mock_ansible_module.params = self.FABRIC_PARAMS_DATA_IS_EQUALS FabricModule().run() self.resource.update_reserved_vlan_range.not_been_called() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, msg=NO_CHANGE_MSG, ansible_facts=dict(fabric=self.PRESENT_FABRIC_VLAN_RANGE))
def test_should_update_vlan_range(self): # Mock OneView resource functions self.resource.get_by.return_value = [self.PRESENT_FABRIC_VLAN_RANGE] self.resource.update_reserved_vlan_range.return_value = self.PRESENT_FABRIC_VLAN_RANGE # Mock Ansible params self.mock_ansible_module.params = self.FABRIC_PARAMS FabricModule().run() self.resource.update_reserved_vlan_range.assert_called_once_with( self.PRESENT_FABRIC_VLAN_RANGE["uri"], self.EXPECTED_FABRIC_VLAN_RANGE) self.mock_ansible_module.exit_json.assert_called_once_with( changed=True, ansible_facts=dict(fabric=self.PRESENT_FABRIC_VLAN_RANGE))