def test_get_vm_size_16_y(self, fake_virtual_memory, fake_get_raw_input): total_mock = Mock() total_mock.total = 16 * 2**30 fake_virtual_memory.return_value = total_mock fake_get_raw_input.return_value = 'y' self.assertEqual(_get_vm_size(), 6144) fake_get_raw_input.assert_has_calls([call('Your system seems to have 16384 megabytes of memory. We would like to allocate 6144 to your vm. Is that ok? (y/n) ')])
def test_get_vm_size_less_8_n(self, fake_virtual_memory, fake_get_raw_input): total_mock = Mock() total_mock.total = 6 * 2**30 fake_virtual_memory.return_value = total_mock fake_get_raw_input.side_effect = ['n', 1] self.assertEqual(_get_vm_size(), 1) fake_get_raw_input.assert_has_calls([call('Your system seems to have 6144 megabytes of memory. We would like to allocate 2048 to your vm. Is that ok? (y/n) '), call('Please input the number of megabytes to allocate to the vm: ')])
def test_get_vm_size_8_y(self, fake_virtual_memory, fake_get_raw_input): total_mock = Mock() total_mock.total = 8 * 2**30 fake_virtual_memory.return_value = total_mock fake_get_raw_input.return_value = 'y' self.assertEqual(_get_vm_size(), 4096) fake_get_raw_input.assert_has_calls([ call( 'Your system seems to have 8192 megabytes of memory. We would like to allocate 4096 to your vm. Is that ok? (y/n) ' ) ])
def test_get_vm_size_8_n(self, fake_virtual_memory, fake_get_raw_input): total_mock = Mock() total_mock.total = 8 * 2**30 fake_virtual_memory.return_value = total_mock fake_get_raw_input.side_effect = ['n', 2] self.assertEqual(_get_vm_size(), 2) fake_get_raw_input.assert_has_calls([ call( 'Your system seems to have 8192 megabytes of memory. We would like to allocate 4096 to your vm. Is that ok? (y/n) ' ), call( 'Please input the number of megabytes to allocate to the vm: ') ])