Пример #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.get_data(endpoint, resource_id,
                         subresource).get('version_details'))
Пример #2
0
    def testArgs_GettingNoncachedData(self, mock_get, data, endpoint,
                                      resource_id):

        mock_get.return_value.json.return_value = data

        # assert that the data is not in the cache
        with shelve.open(cache.API_CACHE) as cache_file:
            key = cache_uri_build(endpoint, resource_id)
            if key in cache_file.keys():
                del cache_file[key]

        self.assertEqual(data, api.get_data(endpoint, resource_id))
Пример #3
0
 def testArgs_GettingCachedData(self, data, endpoint, resource_id):
     assume(data != dict())
     # save some data to the cache
     save(data, endpoint, resource_id)
     self.assertEqual(data, api.get_data(endpoint, resource_id))
Пример #4
0
 def testArg_resource_id_Text(self, endpoint, resource_id):
     with self.assertRaises(ValueError):
         api.get_data(endpoint, resource_id)