def test_get_enclosure_by_name_without_matching_name(self): self.resource.get_by_name.return_value = None self.mock_ansible_module.params = PARAMS_GET_BY_NAME EnclosureFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(enclosures=[]))
def test_should_get_all_enclosures(self): self.resource.get_all.return_value = PRESENT_ENCLOSURES self.mock_ansible_module.params = PARAMS_GET_ALL EnclosureFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(enclosures=(PRESENT_ENCLOSURES)))
def test_should_get_enclosure_by_name(self): self.enclosures.get_by.return_value = PRESENT_ENCLOSURES self.mock_ansible_module.params = PARAMS_GET_BY_NAME EnclosureFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(enclosures=(PRESENT_ENCLOSURES)))
def test_should_get_all_utilization_data(self): self.resource.data = PRESENT_ENCLOSURES self.resource.get_by_name.return_value = self.resource self.resource.get_script.return_value = ENCLOSURE_SCRIPT self.resource.get_utilization.return_value = ENCLOSURE_UTILIZATION self.resource.get_environmental_configuration.return_value = ENCLOSURE_ENVIRONMENTAL_CONFIG self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITH_OPTIONS EnclosureFactsModule().run() self.resource.get_utilization.assert_called_once_with(fields='', filter='', view='', refresh='')
def test_should_get_enclosure_by_name_with_options(self): self.enclosures.get_by.return_value = PRESENT_ENCLOSURES self.enclosures.get_script.return_value = ENCLOSURE_SCRIPT self.enclosures.get_utilization.return_value = ENCLOSURE_UTILIZATION self.enclosures.get_environmental_configuration.return_value = ENCLOSURE_ENVIRONMENTAL_CONFIG self.mock_ansible_module.params = PARAMS_GET_BY_NAME_WITH_OPTIONS EnclosureFactsModule().run() self.mock_ansible_module.exit_json.assert_called_once_with( changed=False, ansible_facts=dict(enclosures=PRESENT_ENCLOSURES, enclosure_script=ENCLOSURE_SCRIPT, enclosure_environmental_configuration= ENCLOSURE_ENVIRONMENTAL_CONFIG, enclosure_utilization=ENCLOSURE_UTILIZATION))
def test_should_get_utilization_with_parameters(self): self.enclosures.get_by.return_value = PRESENT_ENCLOSURES self.enclosures.get_script.return_value = ENCLOSURE_SCRIPT self.enclosures.get_utilization.return_value = ENCLOSURE_UTILIZATION self.enclosures.get_environmental_configuration.return_value = ENCLOSURE_ENVIRONMENTAL_CONFIG self.mock_ansible_module.params = PARAMS_GET_UTILIZATION_WITH_PARAMS EnclosureFactsModule().run() date_filter = [ "startDate=2016-06-30T03:29:42.000Z", "endDate=2016-07-01T03:29:42.000Z" ] self.enclosures.get_utilization.assert_called_once_with( PRESENT_ENCLOSURES[0]['uri'], fields='AveragePower', filter=date_filter, view='day', refresh=True)