Ejemplo n.º 1
0
    def test_security_group_detailed(self):
        request = self.mock_rest_request()
        self.mock_security_group_list.return_value = \
            self.security_groups.list()

        response = network.SecurityGroups().get(request)
        self.assertStatusCode(response, 200)
        self.assertEqual(
            response.json,
            {"items": [sg.to_dict() for sg in self.security_groups.list()]})
        self.mock_security_group_list.assert_called_once_with(request)
    def test_security_group_detailed(self, client):
        request = self.mock_rest_request()
        client.security_group_list.return_value = [
            mock.Mock(**{'to_dict.return_value': {'name': 'default'}}),
        ]

        response = network.SecurityGroups().get(request)
        self.assertStatusCode(response, 200)
        self.assertEqual(response.json,
                         {"items": [{"name": "default"}]})
        client.security_group_list.assert_called_once_with(request)