def test_trunks_get(self, client): request = self.mock_rest_request(GET=django_request.QueryDict()) client.trunk_list.return_value = self.trunks.list() response = neutron.Trunks().get(request) self.assertStatusCode(response, 200) self.assertItemsCollectionEqual( response, [t.to_dict() for t in self.trunks.list()])
def test_trunks_create(self, client): request = self.mock_rest_request(body=''' {"name": "trunk1", "port_id": 1} ''') client.trunk_create.return_value = self._trunks[0] response = neutron.Trunks().post(request) self.assertStatusCode(response, 201) self.assertEqual(response.json, TEST.api_trunks.first())
def test_trunks_create(self, mock_trunk_create): request = self.mock_rest_request(body=''' {"name": "trunk1", "port_id": "1"} ''') trunk = self.trunks.first() mock_trunk_create.return_value = trunk response = neutron.Trunks().post(request) self.assertStatusCode(response, 201) self.assertEqual(response.json, trunk.to_dict()) mock_trunk_create.assert_called_once_with(request, name='trunk1', port_id='1')