async def test_run(self, event_loop): change = AddMachineChange(1, [], params={ "series": "series", "constraints": "cores=1", "container-type": "container_type", "parent-id": "parent_id" }) machines = [client.AddMachinesResult(machine="machine1")] client_facade = mock.Mock() client_facade.AddMachines = base.AsyncMock( return_value=client.AddMachinesResults(machines)) context = mock.Mock() context.resolve.return_value = "parent_id1" context.client_facade = client_facade result = await change.run(context) assert result == "machine1" client_facade.AddMachines.assert_called_once() client_facade.AddMachines.assert_called_with(params=[ client.AddMachineParams(series="series", constraints="{\"cores\":1}", container_type="container_type", parent_id="parent_id1", jobs=["JobHostUnits"]) ])
def test_dict_params_missing_data(self): change = AddMachineChange(1, [], params={"series": "series", "constraints": "constraints", "container-type": "container_type"}) self.assertEqual({"change_id": 1, "requires": [], "series": "series", "constraints": "constraints", "container_type": "container_type", "parent_id": None}, change.__dict__)
def test_list_params(self): change = AddMachineChange(1, [], params=[{"series": "series", "constraints": "constraints", "containerType": "container_type", "parentId": "parent_id"}]) self.assertEqual({"change_id": 1, "requires": [], "series": "series", "constraints": "constraints", "container_type": "container_type", "parent_id": "parent_id"}, change.__dict__)
def test_method(self): self.assertEqual("addMachines", AddMachineChange.method())