예제 #1
0
    def test_save_usage_should_persist_image_usage(self):
        raw = self.mox.CreateMockAnything()
        size = 123
        uuid = "2df2ccf6-bc1b-4853-aab0-25fda346b3bb"
        body = {
            "event_type": "image.upload",
            "timestamp": "2013-06-20 18:31:57.939614",
            "publisher_id":
            "glance-api01-r2961.global.preprod-ord.ohthree.com",
            "payload": {
                "created_at": str(DUMMY_TIME),
                "size": size,
                "owner": TENANT_ID_1,
                "id": "2df2ccf6-bc1b-4853-aab0-25fda346b3bb",
            }
        }
        deployment = "1"
        routing_key = "glance_monitor.info"
        json_body = json.dumps([routing_key, body])

        self.mox.StubOutWithMock(db, 'create_image_usage')
        db.create_image_usage(created_at=utils.str_time_to_unix(
            str(DUMMY_TIME)),
                              owner=TENANT_ID_1,
                              last_raw=raw,
                              size=size,
                              uuid=uuid).AndReturn(raw)
        self.mox.ReplayAll()

        notification = GlanceNotification(body, deployment, routing_key,
                                          json_body)
        notification.save_usage(raw)
        self.mox.VerifyAll()
예제 #2
0
    def test_save_usage_should_persist_image_usage(self):
        raw = self.mox.CreateMockAnything()
        size = 123
        uuid = "2df2ccf6-bc1b-4853-aab0-25fda346b3bb"
        body = {
            "event_type": "image.upload",
            "timestamp": "2013-06-20 18:31:57.939614",
            "publisher_id": "glance-api01-r2961.global.preprod-ord.ohthree.com",
            "payload": {
                "created_at": str(DUMMY_TIME),
                "size": size,
                "owner": TENANT_ID_1,
                "id": "2df2ccf6-bc1b-4853-aab0-25fda346b3bb",
            }
        }
        deployment = "1"
        routing_key = "glance_monitor.info"
        json = '{["routing_key", {%s}]}' % body

        self.mox.StubOutWithMock(db, 'create_image_usage')
        db.create_image_usage(
            created_at=utils.str_time_to_unix(str(DUMMY_TIME)),
            owner=TENANT_ID_1,
            last_raw=raw,
            size=size,
            uuid=uuid).AndReturn(raw)
        self.mox.ReplayAll()

        notification = GlanceNotification(body, deployment, routing_key, json)
        notification.save_usage(raw)
        self.mox.VerifyAll()
예제 #3
0
    def test_save_image_usage(self):
        raw = self.mox.CreateMockAnything()
        notification = self.mox.CreateMockAnything()
        notification.save_usage(raw)
        self.mox.ReplayAll()

        views._process_glance_usage(raw, notification)
        self.mox.VerifyAll()
예제 #4
0
    def test_save_image_usage(self):
        raw = self.mox.CreateMockAnything()
        notification = self.mox.CreateMockAnything()
        notification.save_usage(raw)
        self.mox.ReplayAll()

        views._process_glance_usage(raw, notification)
        self.mox.VerifyAll()
예제 #5
0
def _process_glance_usage(raw, notification):
    notification.save_usage(raw)
예제 #6
0
파일: views.py 프로젝트: jtopjian/stacktach
def _process_glance_usage(raw, notification):
    notification.save_usage(raw)