示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
 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)
示例#10
0
 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)
示例#11
0
 def test_without_content(self):
     router_event = utils.get_router_event()
     router_event.pop('content')
     self.post_json('/events', router_event, expect_errors=True)
示例#12
0
 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)
示例#13
0
 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)
示例#14
0
 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)
示例#15
0
 def test_without_content(self):
     router_event = utils.get_router_event()
     router_event.pop('content')
     self.post_json('/events', router_event, expect_errors=True)
示例#16
0
 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)