test_openstack.py (salt-3002.1) | : | test_openstack.py (salt-3002.2) | ||
---|---|---|---|---|
skipping to change at line 188 | skipping to change at line 188 | |||
fake_conn = MagicMock() | fake_conn = MagicMock() | |||
expected_network = {"foo": "bar"} | expected_network = {"foo": "bar"} | |||
vm_ = {"name": "fnord", "driver": "fnord", "network": expected_network} | vm_ = {"name": "fnord", "driver": "fnord", "network": expected_network} | |||
patch_utils = patch.dict( | patch_utils = patch.dict( | |||
openstack.__utils__, | openstack.__utils__, | |||
{"cloud.check_name": MagicMock(), "dictupdate.update": dictupdate.up date}, | {"cloud.check_name": MagicMock(), "dictupdate.update": dictupdate.up date}, | |||
) | ) | |||
with patch_utils: | with patch_utils: | |||
openstack.request_instance(vm_=vm_, conn=fake_conn) | openstack.request_instance(vm_=vm_, conn=fake_conn) | |||
call = fake_conn.create_server.mock_calls[0] | call_kwargs = fake_conn.create_server.mock_calls[0][-1] | |||
self.assertDictEqual(call.kwargs["network"], expected_network) | self.assertDictEqual(call_kwargs["network"], expected_network) | |||
# Here we're testing the list of dictionaries | # Here we're testing the list of dictionaries | |||
def test_request_instance_should_be_able_to_provide_a_list_of_dictionaries_f or_network( | def test_request_instance_should_be_able_to_provide_a_list_of_dictionaries_f or_network( | |||
self, | self, | |||
): | ): | |||
fake_conn = MagicMock() | fake_conn = MagicMock() | |||
expected_network = [{"foo": "bar"}, {"bang": "quux"}] | expected_network = [{"foo": "bar"}, {"bang": "quux"}] | |||
vm_ = {"name": "fnord", "driver": "fnord", "network": expected_network} | vm_ = {"name": "fnord", "driver": "fnord", "network": expected_network} | |||
patch_utils = patch.dict( | patch_utils = patch.dict( | |||
openstack.__utils__, | openstack.__utils__, | |||
{"cloud.check_name": MagicMock(), "dictupdate.update": dictupdate.up date}, | {"cloud.check_name": MagicMock(), "dictupdate.update": dictupdate.up date}, | |||
) | ) | |||
with patch_utils: | with patch_utils: | |||
openstack.request_instance(vm_=vm_, conn=fake_conn) | openstack.request_instance(vm_=vm_, conn=fake_conn) | |||
call = fake_conn.create_server.mock_calls[0] | call_kwargs = fake_conn.create_server.mock_calls[0][-1] | |||
assert call.kwargs["network"] == expected_network | assert call_kwargs["network"] == expected_network | |||
# Here we're testing for names/IDs | # Here we're testing for names/IDs | |||
def test_request_instance_should_be_able_to_provide_a_list_of_single_ids_or_ names_for_network( | def test_request_instance_should_be_able_to_provide_a_list_of_single_ids_or_ names_for_network( | |||
self, | self, | |||
): | ): | |||
fake_conn = MagicMock() | fake_conn = MagicMock() | |||
expected_network = ["foo", "bar", "bang", "fnord1", "fnord2"] | expected_network = ["foo", "bar", "bang", "fnord1", "fnord2"] | |||
vm_ = {"name": "fnord", "driver": "fnord", "network": expected_network} | vm_ = {"name": "fnord", "driver": "fnord", "network": expected_network} | |||
patch_utils = patch.dict( | patch_utils = patch.dict( | |||
openstack.__utils__, | openstack.__utils__, | |||
{"cloud.check_name": MagicMock(), "dictupdate.update": dictupdate.up date}, | {"cloud.check_name": MagicMock(), "dictupdate.update": dictupdate.up date}, | |||
) | ) | |||
with patch_utils: | with patch_utils: | |||
openstack.request_instance(vm_=vm_, conn=fake_conn) | openstack.request_instance(vm_=vm_, conn=fake_conn) | |||
call = fake_conn.create_server.mock_calls[0] | call_kwargs = fake_conn.create_server.mock_calls[0][-1] | |||
assert call.kwargs["network"] == expected_network | assert call_kwargs["network"] == expected_network | |||
# Testing that we get a dict that we expect for create_server | # Testing that we get a dict that we expect for create_server | |||
def test__clean_create_kwargs(self): | def test__clean_create_kwargs(self): | |||
params = { | params = { | |||
"name": "elmer", | "name": "elmer", | |||
"image": "mirrormirror", | "image": "mirrormirror", | |||
"flavor": "chocolate", | "flavor": "chocolate", | |||
"auto_ip": True, | "auto_ip": True, | |||
"ips": ["hihicats"], | "ips": ["hihicats"], | |||
"ip_pool": "olympic", | "ip_pool": "olympic", | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |