def test_basic(self): sot = resource.Resource(EXAMPLE) self.assertIsNone(sot.resource_key) self.assertIsNone(sot.resources_key) self.assertEqual('/v2/resources', sot.base_path) self.assertEqual('metering', sot.service.service_type) self.assertFalse(sot.allow_create) self.assertTrue(sot.allow_retrieve) self.assertFalse(sot.allow_update) self.assertFalse(sot.allow_delete) self.assertTrue(sot.allow_list)
def test_make_it(self): sot = resource.Resource(EXAMPLE) self.assertEqual(EXAMPLE['resource_id'], sot.id) self.assertEqual(EXAMPLE['first_sample_timestamp'], sot.first_sample_at) self.assertEqual(EXAMPLE['last_sample_timestamp'], sot.last_sample_at) self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['metadata'], sot.metadata) self.assertEqual(EXAMPLE['project_id'], sot.project_id) self.assertEqual(EXAMPLE['resource_id'], sot.resource_id) self.assertEqual(EXAMPLE['source'], sot.source) self.assertEqual(EXAMPLE['user_id'], sot.user_id)
def test_make_it(self): sot = resource.Resource(EXAMPLE) self.assertEqual(EXAMPLE['resource_id'], sot.id) dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace(tzinfo=None) self.assertEqual(dt, sot.first_sample_at.replace(tzinfo=None)) dt = datetime.datetime(2015, 3, 9, 12, 15, 57, 233772).replace(tzinfo=None) self.assertEqual(dt, sot.last_sample_at.replace(tzinfo=None)) self.assertEqual(EXAMPLE['links'], sot.links) self.assertEqual(EXAMPLE['metadata'], sot.metadata) self.assertEqual(EXAMPLE['project_id'], sot.project_id) self.assertEqual(EXAMPLE['resource_id'], sot.resource_id) self.assertEqual(EXAMPLE['source'], sot.source) self.assertEqual(EXAMPLE['user_id'], sot.user_id)
def get_resource(self, **data): return resource.Resource(data).get(self.session)