def test_with_wrong_event_time(self): router_event = utils.get_router_event() router_event['event_time'] = '2015-10-21T01:00:00.000000' self.post_json('/events', router_event) router_event = utils.get_router_event() router_event['event_time'] = '2015-09-21T01:00:00.000000' router_event['event_type'] = 'exists' self.post_json('/events', router_event, expect_errors=True)
def test_create_delete_exists_event_success(self): router_event = utils.get_router_event() router_event['event_time'] = '2015-10-01T01:00:00.000000' self.post_json('/events', router_event) router_event['event_time'] = '2015-10-11T01:00:00.000000' router_event['event_type'] = 'delete' self.post_json('/events', router_event) url = '/resources/' + router_event['resource_id'] res = self.get_json(url) self.assertEqual(res['status'], 'delete') self.assertEqual(int(res['consumption']), 240) router_event['event_time'] = '2015-10-21T01:00:00.000000' router_event['event_type'] = 'exists' self.post_json('/events', router_event, expect_errors=True) url = '/resources/' + router_event['resource_id'] res = self.get_json(url) self.assertEqual(res['status'], 'delete') self.assertEqual(int(res['consumption']), 240) url = '/records/' + router_event['resource_id'] records = self.get_json(url) self.assertEqual(len(records), 1)
def test_post_delete_event_success(self): router_event = utils.get_router_event() router_event['event_type'] = 'delete' self.post_json('/events', router_event) url = '/resources/' + router_event['resource_id'] self.get_json(url, expect_errors=True) url = '/records/' + router_event['resource_id'] self.get_json(url, expect_errors=True)
def test_post_create_event_success(self): router_event = utils.get_router_event() self.post_json('/events', router_event) url = '/resources/' + router_event['resource_id'] res = self.get_json(url) self.assertEqual(res['status'], 'active') url = '/records/' + router_event['resource_id'] self.get_json(url, expect_errors=True)
def test_with_wrong_event_type(self): router_event = utils.get_router_event() router_event['event_type'] = 'resize' self.post_json('/events', router_event, expect_errors=True)
def test_with_wrong_content(self): router_event = utils.get_router_event() router_event['content'] = 'wrong_content' self.post_json('/events', router_event, expect_errors=True)
def test_without_content(self): router_event = utils.get_router_event() router_event.pop('content') self.post_json('/events', router_event, expect_errors=True)
def test_without_resource_id(self): router_event = utils.get_router_event() router_event.pop('resource_id') self.post_json('/events', router_event, expect_errors=True)