Exemplo n.º 1
0
 def __init__(self, api_info, data):
     self._api = api_info
     self._client = APIWrapper(api_info.key, api_info.http_client,
                               api_info.base, api_info.version)
     self.data = data
     self.id = data['id']
     parse_dts(self.data)
Exemplo n.º 2
0
    def test_media_retrieve(self):
        self.mock_api.media.update(MEDIA)
        mock_id = '19adeea0-88e0-d8fb-c899-864502a1011f'
        media = self.api.media.retrieve(mock_id)
        media_copy = copy.deepcopy(MEDIA[mock_id])
        parse_dts(media_copy)
        self.assertDictEqual(media_copy, media.data)

        self.mock_api.media[mock_id]['status'] = 'CHANGED'
        media.retrieve()
        self.assertEqual(media.data['status'], 'CHANGED')
Exemplo n.º 3
0
 def test_parsing_dts(self):
     data = {
         object(): object(),
         'xy': 22,
         'x_at': 1,
         'created_at': '2014-10-20T17:37:45+00:00',
         'invalid_at': '2014-10-20T17:37:'
     }
     utils.parse_dts(data)
     self.assertEqual(data['xy'], 22)
     self.assertEqual(data['x_at'], 1)
     self.assertEqual(data['created_at'],
                      datetime(2014, 10, 20, 17, 37, 45, tzinfo=tzutc()))
     self.assertEqual(data['invalid_at'], '2014-10-20T17:37:')
Exemplo n.º 4
0
 def __init__(self, api_info, data):
     self._api = api_info
     self._client = APIWrapper(api_info.key, api_info.http_client, api_info.base, api_info.version)
     self.data = data
     self.id = data["id"]
     parse_dts(self.data)