Пример #1
0
    def testArg_subresource_Text(self, mock_get, endpoint, resource_id,
                                 subresource):
        mock_get.return_value.json.return_value = {'version_details': 'foo'}

        self.assertIsNotNone(
            api._call_api(endpoint, resource_id,
                          subresource).get('version_details'))
Пример #2
0
    def testArg_resource_id_None(self, mock_get, endpoint, resource_id):

        mock_get.return_value.json.return_value = {
            'count': 100,
            'results': ['some', 'reults']
        }

        self.assertIsNotNone(api._call_api(endpoint, resource_id).get('count'))
Пример #3
0
    def testEnv_ErrorResponse(self, mock_get, endpoint, resource_id):
        mock_get.return_value.raise_for_status.side_effect = HTTPError()

        with self.assertRaises(HTTPError):
            api._call_api(endpoint, resource_id)
Пример #4
0
 def testArg_endpoint_Text(self, endpoint, resource_id):
     with self.assertRaises(ValueError):
         api._call_api(endpoint, resource_id)
Пример #5
0
    def testArgs(self, mock_get, endpoint, resource_id):

        mock_get.return_value.json.return_value = {'id': resource_id}

        self.assertEqual(
            api._call_api(endpoint, resource_id)['id'], resource_id)