mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
Reformat everything.
This commit is contained in:
@@ -10,53 +10,41 @@ import unittest
|
||||
from ansible_collections.community.general.plugins.modules.oneview_enclosure_info import EnclosureInfoModule
|
||||
|
||||
|
||||
ERROR_MSG = 'Fake message error'
|
||||
ERROR_MSG = "Fake message error"
|
||||
|
||||
PARAMS_GET_ALL = dict(
|
||||
config='config.json',
|
||||
name=None
|
||||
)
|
||||
PARAMS_GET_ALL = dict(config="config.json", name=None)
|
||||
|
||||
PARAMS_GET_BY_NAME = dict(
|
||||
config='config.json',
|
||||
name="Test-Enclosure",
|
||||
options=[]
|
||||
)
|
||||
PARAMS_GET_BY_NAME = dict(config="config.json", name="Test-Enclosure", options=[])
|
||||
|
||||
PARAMS_GET_BY_NAME_WITH_OPTIONS = dict(
|
||||
config='config.json',
|
||||
name="Test-Enclosure",
|
||||
options=['utilization', 'environmentalConfiguration', 'script']
|
||||
config="config.json", name="Test-Enclosure", options=["utilization", "environmentalConfiguration", "script"]
|
||||
)
|
||||
|
||||
PARAMS_GET_UTILIZATION_WITH_PARAMS = dict(
|
||||
config='config.json',
|
||||
config="config.json",
|
||||
name="Test-Enclosure",
|
||||
options=[dict(utilization=dict(fields='AveragePower',
|
||||
filter=['startDate=2016-06-30T03:29:42.000Z',
|
||||
'endDate=2016-07-01T03:29:42.000Z'],
|
||||
view='day',
|
||||
refresh=True))]
|
||||
options=[
|
||||
dict(
|
||||
utilization=dict(
|
||||
fields="AveragePower",
|
||||
filter=["startDate=2016-06-30T03:29:42.000Z", "endDate=2016-07-01T03:29:42.000Z"],
|
||||
view="day",
|
||||
refresh=True,
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
PRESENT_ENCLOSURES = [{
|
||||
"name": "Test-Enclosure",
|
||||
"uri": "/rest/enclosures/c6bf9af9-48e7-4236-b08a-77684dc258a5"
|
||||
}]
|
||||
PRESENT_ENCLOSURES = [{"name": "Test-Enclosure", "uri": "/rest/enclosures/c6bf9af9-48e7-4236-b08a-77684dc258a5"}]
|
||||
|
||||
ENCLOSURE_SCRIPT = '# script content'
|
||||
ENCLOSURE_SCRIPT = "# script content"
|
||||
|
||||
ENCLOSURE_UTILIZATION = {
|
||||
"isFresh": "True"
|
||||
}
|
||||
ENCLOSURE_UTILIZATION = {"isFresh": "True"}
|
||||
|
||||
ENCLOSURE_ENVIRONMENTAL_CONFIG = {
|
||||
"calibratedMaxPower": "2500"
|
||||
}
|
||||
ENCLOSURE_ENVIRONMENTAL_CONFIG = {"calibratedMaxPower": "2500"}
|
||||
|
||||
|
||||
class EnclosureInfoSpec(unittest.TestCase,
|
||||
FactsParamsTestCase):
|
||||
class EnclosureInfoSpec(unittest.TestCase, FactsParamsTestCase):
|
||||
def setUp(self):
|
||||
self.configure_mocks(self, EnclosureInfoModule)
|
||||
self.enclosures = self.mock_ov_client.enclosures
|
||||
@@ -68,10 +56,7 @@ class EnclosureInfoSpec(unittest.TestCase,
|
||||
|
||||
EnclosureInfoModule().run()
|
||||
|
||||
self.mock_ansible_module.exit_json.assert_called_once_with(
|
||||
changed=False,
|
||||
enclosures=(PRESENT_ENCLOSURES)
|
||||
)
|
||||
self.mock_ansible_module.exit_json.assert_called_once_with(changed=False, enclosures=(PRESENT_ENCLOSURES))
|
||||
|
||||
def test_should_get_enclosure_by_name(self):
|
||||
self.enclosures.get_by.return_value = PRESENT_ENCLOSURES
|
||||
@@ -79,11 +64,7 @@ class EnclosureInfoSpec(unittest.TestCase,
|
||||
|
||||
EnclosureInfoModule().run()
|
||||
|
||||
self.mock_ansible_module.exit_json.assert_called_once_with(
|
||||
changed=False,
|
||||
enclosures=(PRESENT_ENCLOSURES)
|
||||
|
||||
)
|
||||
self.mock_ansible_module.exit_json.assert_called_once_with(changed=False, enclosures=(PRESENT_ENCLOSURES))
|
||||
|
||||
def test_should_get_enclosure_by_name_with_options(self):
|
||||
self.enclosures.get_by.return_value = PRESENT_ENCLOSURES
|
||||
@@ -100,7 +81,7 @@ class EnclosureInfoSpec(unittest.TestCase,
|
||||
enclosures=PRESENT_ENCLOSURES,
|
||||
enclosure_script=ENCLOSURE_SCRIPT,
|
||||
enclosure_environmental_configuration=ENCLOSURE_ENVIRONMENTAL_CONFIG,
|
||||
enclosure_utilization=ENCLOSURE_UTILIZATION
|
||||
enclosure_utilization=ENCLOSURE_UTILIZATION,
|
||||
)
|
||||
|
||||
def test_should_get_all_utilization_data(self):
|
||||
@@ -113,8 +94,9 @@ class EnclosureInfoSpec(unittest.TestCase,
|
||||
|
||||
EnclosureInfoModule().run()
|
||||
|
||||
self.enclosures.get_utilization.assert_called_once_with(PRESENT_ENCLOSURES[0]['uri'], fields='', filter='',
|
||||
view='', refresh='')
|
||||
self.enclosures.get_utilization.assert_called_once_with(
|
||||
PRESENT_ENCLOSURES[0]["uri"], fields="", filter="", view="", refresh=""
|
||||
)
|
||||
|
||||
def test_should_get_utilization_with_parameters(self):
|
||||
self.enclosures.get_by.return_value = PRESENT_ENCLOSURES
|
||||
@@ -129,8 +111,9 @@ class EnclosureInfoSpec(unittest.TestCase,
|
||||
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)
|
||||
PRESENT_ENCLOSURES[0]["uri"], fields="AveragePower", filter=date_filter, view="day", refresh=True
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user