Ejemplo n.º 1
0
    def test_upload_delete_exists_event_success(self):
        image_event = utils.get_image_event()
        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event)

        image_event['event_type'] = 'delete'
        image_event['event_time'] = '2015-10-11T01:00:00.000000'
        self.post_json('/events', image_event)

        url = '/resources/' + image_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'delete')
        self.assertEqual(int(res['consumption']), 2400)

        image_event['event_type'] = 'exists'
        image_event['event_time'] = '2015-10-21T01:00:00.000000'
        self.post_json('/events', image_event, expect_errors=True)

        url = '/resources/' + image_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'delete')
        self.assertEqual(int(res['consumption']), 2400)

        url = '/records/' + image_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)
        self.assertEqual(int(records[0]['consumption']), 2400)
Ejemplo n.º 2
0
    def test_upload_delete_exists_event_success(self):
        image_event = utils.get_image_event()
        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event)

        image_event['event_type'] = 'delete'
        image_event['event_time'] = '2015-10-11T01:00:00.000000'
        self.post_json('/events', image_event)

        url = '/resources/' + image_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'delete')
        self.assertEqual(int(res['consumption']), 2400)

        image_event['event_type'] = 'exists'
        image_event['event_time'] = '2015-10-21T01:00:00.000000'
        self.post_json('/events', image_event, expect_errors=True)

        url = '/resources/' + image_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'delete')
        self.assertEqual(int(res['consumption']), 2400)

        url = '/records/' + image_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)
        self.assertEqual(int(records[0]['consumption']), 2400)
Ejemplo n.º 3
0
    def test_upload_upload_event_fail(self):
        image_event = utils.get_image_event()
        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event)

        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 4
0
    def test_upload_upload_event_fail(self):
        image_event = utils.get_image_event()
        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event)

        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 5
0
    def test_with_wrong_event_time(self):
        image_event = utils.get_image_event()
        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event)

        image_event['event_type'] = 'exists'
        image_event['event_time'] = '2015-09-01T01:00:00.000000'
        self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 6
0
    def test_with_wrong_event_time(self):
        image_event = utils.get_image_event()
        image_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', image_event)

        image_event['event_type'] = 'exists'
        image_event['event_time'] = '2015-09-01T01:00:00.000000'
        self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 7
0
    def test_post_delete_event_success(self):
        image_event = utils.get_image_event()
        image_event['event_type'] = 'delete'
        self.post_json('/events', image_event)

        url = '/resources/' + image_event['resource_id']
        self.get_json(url, expect_errors=True)

        url = '/records/' + image_event['resource_id']
        self.get_json(url, expect_errors=True)
Ejemplo n.º 8
0
    def test_post_delete_event_success(self):
        image_event = utils.get_image_event()
        image_event['event_type'] = 'delete'
        self.post_json('/events', image_event)

        url = '/resources/' + image_event['resource_id']
        self.get_json(url, expect_errors=True)

        url = '/records/' + image_event['resource_id']
        self.get_json(url, expect_errors=True)
Ejemplo n.º 9
0
    def test_post_upload_event_success(self):
        image_event = utils.get_image_event()
        self.post_json('/events', image_event)

        url = '/resources/' + image_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'active')
        self.assertEqual(int(res['consumption']), 0)

        url = '/records/' + image_event['resource_id']
        self.get_json(url, expect_errors=True)
Ejemplo n.º 10
0
    def test_post_upload_event_success(self):
        image_event = utils.get_image_event()
        self.post_json('/events', image_event)

        url = '/resources/' + image_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'active')
        self.assertEqual(int(res['consumption']), 0)

        url = '/records/' + image_event['resource_id']
        self.get_json(url, expect_errors=True)
Ejemplo n.º 11
0
 def test_without_wrong_type(self):
     image_event = utils.get_image_event()
     image_event['event_type'] = 'create'
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 12
0
 def test_without_wrong_size_in_content(self):
     image_event = utils.get_image_event()
     image_event['content']['size'] = 'wrong_size'
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 13
0
 def test_without_wrong_content(self):
     image_event = utils.get_image_event()
     image_event.pop('content')
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 14
0
 def test_without_tenant_id(self):
     image_event = utils.get_image_event()
     image_event.pop('tenant_id')
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 15
0
 def test_without_tenant_id(self):
     image_event = utils.get_image_event()
     image_event.pop('tenant_id')
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 16
0
 def test_without_wrong_type(self):
     image_event = utils.get_image_event()
     image_event['event_type'] = 'create'
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 17
0
 def test_without_wrong_size_in_content(self):
     image_event = utils.get_image_event()
     image_event['content']['size'] = 'wrong_size'
     self.post_json('/events', image_event, expect_errors=True)
Ejemplo n.º 18
0
 def test_without_wrong_content(self):
     image_event = utils.get_image_event()
     image_event.pop('content')
     self.post_json('/events', image_event, expect_errors=True)