Created
November 6, 2021 02:37
-
-
Save RyanKor/e8ffb42774eedc0470a9750bae6214b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestHypervisorUpTime(TestHypervisor): | |
def setUp(self): | |
super(TestHypervisorUpTime, self).setUp() | |
# Fake hypervisors to be listed up | |
self.hypervisor = compute_fakes.FakeHypervisor.create_one_hypervisor() | |
# Return value of utils.find_resource() | |
self.hypervisors_mock.get.return_value = self.hypervisor | |
# Return value of compute_client.hypervisors.uptime() | |
uptime_info = { | |
'status': self.hypervisor.status, | |
'state': self.hypervisor.state, | |
'id': self.hypervisor.id, | |
'hypervisor_hostname': self.hypervisor.hypervisor_hostname, | |
'uptime': ' 01:28:24 up 3 days, 11:15, 1 user, ' | |
' load average: 0.94, 0.62, 0.50\n', | |
} | |
self.hypervisors_mock.uptime.return_value = fakes.FakeResource( | |
info=copy.deepcopy(uptime_info), | |
loaded=True | |
) | |
self.columns = ( | |
'hypervisor_hostname', | |
'id', | |
'state', | |
'status', | |
'uptime', | |
) | |
self.data = ( | |
self.hypervisor.hypervisor_hostname, | |
self.hypervisor.id, | |
self.hypervisor.state, | |
self.hypervisor.status, | |
' 01:28:24 up 3 days, 11:15, 1 user, ' | |
' load average: 0.94, 0.62, 0.50\n', | |
) | |
# Get the command object to test | |
self.cmd = hypervisor.UpTimeHypervisor(self.app, None) | |
def test_hypervisor_uptime(self): | |
arglist = [ | |
self.hypervisor.hypervisor_hostname, | |
] | |
verifylist = [ | |
('hypervisor', self.hypervisor.hypervisor_hostname), | |
] | |
parsed_args = self.check_parser(self.cmd, arglist, verifylist) | |
# In base command class ShowOne in cliff, abstract method take_action() | |
# returns a two-part tuple with a tuple of column names and a tuple of | |
# data to be shown. | |
columns, data = self.cmd.take_action(parsed_args) | |
self.assertEqual(self.columns, columns) | |
self.assertCountEqual(self.data, data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment