コード例 #1
0
    def test_create_exists_delete_with_missing_resize(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        volume_event['event_type'] = 'create'
        self.post_json('/events', volume_event)

        volume_event['event_time'] = '2015-10-11T01:00:00.000000'
        # Missing resize event
        volume_event['content']['size'] = 1000
        volume_event['event_type'] = 'exists'
        self.post_json('/events', volume_event)

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

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

        url = '/resources/' + volume_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(int(res['consumption']), 242400)

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 2)
        self.assertEqual(int(records[0]['consumption']), 2400)
        self.assertEqual(int(records[1]['consumption']), 240000)
コード例 #2
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_exists_resize_delete_event_success(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        volume_event['event_type'] = 'exists'
        self.post_json('/events', volume_event)

        volume_event['event_time'] = '2015-10-11T01:00:00.000000'
        volume_event['content']['size'] = 1000
        volume_event['event_type'] = 'resize'
        self.post_json('/events', volume_event)

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)

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

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 2)
        self.assertEqual(int(records[0]['consumption']), 2400)
        self.assertEqual(int(records[1]['consumption']), 240000)
コード例 #3
0
    def test_exists_resize_delete_event_success(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        volume_event['event_type'] = 'exists'
        self.post_json('/events', volume_event)

        volume_event['event_time'] = '2015-10-11T01:00:00.000000'
        volume_event['content']['size'] = 1000
        volume_event['event_type'] = 'resize'
        self.post_json('/events', volume_event)

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)

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

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 2)
        self.assertEqual(int(records[0]['consumption']), 2400)
        self.assertEqual(int(records[1]['consumption']), 240000)
コード例 #4
0
    def test_create_delete_create_event_success(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        volume_event['event_type'] = 'create'
        self.post_json('/events', volume_event)

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

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)

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

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)
        self.assertEqual(int(records[0]['consumption']), 2400)
コード例 #5
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_with_wrong_size_in_content(self):
        volume_event = utils.get_volume_event()
        volume_event['content']['size'] = 'size'
        self.post_json('/events', volume_event, expect_errors=True)

        volume_event['content']['size'] = -10
        self.post_json('/events', volume_event, expect_errors=True)
コード例 #6
0
    def test_with_wrong_size_in_content(self):
        volume_event = utils.get_volume_event()
        volume_event['content']['size'] = 'size'
        self.post_json('/events', volume_event, expect_errors=True)

        volume_event['content']['size'] = -10
        self.post_json('/events', volume_event, expect_errors=True)
コード例 #7
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_create_exists_delete_with_missing_resize(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        volume_event['event_type'] = 'create'
        self.post_json('/events', volume_event)

        volume_event['event_time'] = '2015-10-11T01:00:00.000000'
        # Missing resize event
        volume_event['content']['size'] = 1000
        volume_event['event_type'] = 'exists'
        self.post_json('/events', volume_event)

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

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

        url = '/resources/' + volume_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(int(res['consumption']), 242400)

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 2)
        self.assertEqual(int(records[0]['consumption']), 2400)
        self.assertEqual(int(records[1]['consumption']), 240000)
コード例 #8
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_create_delete_create_event_success(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        volume_event['event_type'] = 'create'
        self.post_json('/events', volume_event)

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

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)

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

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

        url = '/records/' + volume_event['resource_id']
        records = self.get_json(url)
        self.assertEqual(len(records), 1)
        self.assertEqual(int(records[0]['consumption']), 2400)
コード例 #9
0
    def test_with_wrong_event_time(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', volume_event)

        volume_event['event_time'] = '2015-09-11T01:00:00.000000'
        volume_event['event_type'] = 'exists'
        self.post_json('/events', volume_event, expect_errors=True)
コード例 #10
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_with_wrong_event_time(self):
        volume_event = utils.get_volume_event()
        volume_event['event_time'] = '2015-10-01T01:00:00.000000'
        self.post_json('/events', volume_event)

        volume_event['event_time'] = '2015-09-11T01:00:00.000000'
        volume_event['event_type'] = 'exists'
        self.post_json('/events', volume_event, expect_errors=True)
コード例 #11
0
    def test_post_delete_event_success(self):
        volume_event = utils.get_volume_event()
        volume_event['event_type'] = 'delete'
        self.post_json('/events', volume_event)

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

        url = '/records/' + volume_event['resource_id']
        self.get_json(url, expect_errors=True)
コード例 #12
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_post_delete_event_success(self):
        volume_event = utils.get_volume_event()
        volume_event['event_type'] = 'delete'
        self.post_json('/events', volume_event)

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

        url = '/records/' + volume_event['resource_id']
        self.get_json(url, expect_errors=True)
コード例 #13
0
    def test_post_create_event_success(self):
        volume_event = utils.get_volume_event()
        self.post_json('/events', volume_event)

        url = '/resources/' + volume_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'active')

        url = '/records/' + volume_event['resource_id']
        self.get_json(url, expect_errors=True)
コード例 #14
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
    def test_post_create_event_success(self):
        volume_event = utils.get_volume_event()
        self.post_json('/events', volume_event)

        url = '/resources/' + volume_event['resource_id']
        res = self.get_json(url)
        self.assertEqual(res['status'], 'active')

        url = '/records/' + volume_event['resource_id']
        self.get_json(url, expect_errors=True)
コード例 #15
0
 def test_without_size_in_content(self):
     volume_event = utils.get_volume_event()
     volume_event['content'].pop('size')
     self.post_json('/events', volume_event, expect_errors=True)
コード例 #16
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
 def test_wrong_event_type(self):
     volume_event = utils.get_volume_event()
     volume_event['event_type'] = 'wrong_event_type'
     self.post_json('/events', volume_event, expect_errors=True)
コード例 #17
0
 def test_wrong_event_type(self):
     volume_event = utils.get_volume_event()
     volume_event['event_type'] = 'wrong_event_type'
     self.post_json('/events', volume_event, expect_errors=True)
コード例 #18
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
 def test_without_size_in_content(self):
     volume_event = utils.get_volume_event()
     volume_event['content'].pop('size')
     self.post_json('/events', volume_event, expect_errors=True)
コード例 #19
0
ファイル: test_event_volume.py プロジェクト: DeliangFan/koala
 def test_without_resource_id(self):
     volume_event = utils.get_volume_event()
     volume_event.pop('resource_id')
     self.post_json('/events', volume_event, expect_errors=True)
コード例 #20
0
 def test_without_resource_id(self):
     volume_event = utils.get_volume_event()
     volume_event.pop('resource_id')
     self.post_json('/events', volume_event, expect_errors=True)