Example #1
0
        def mycb(line):
            if 'rowCount' in line:
                return
            if 'type' in line and line['type'] == "error":
                raise Exception(line['message'])

            change = ModelChange.from_json(line)
            if "sortKey" in line:
                c.sortkey = line["sortKey"]
            c.gotany = True
            c.count = c.count + 1
            cb(change)
Example #2
0
        def mycb(line):
            if 'rowCount' in line:
                return
            if 'type' in line and line['type'] == "error":
                raise Exception(line['message'])

            change = ModelChange.from_json(line)
            if "sortKey" in line:
                c.sortkey = line["sortKey"]
            c.gotany = True
            c.count = c.count + 1
            cb(change)
Example #3
0
        def mycb(line):
            if 'rowCount' in line:
                # New gerrit sets 'moreChanges'
                if 'moreChanges' in line:
                    c.has_more = line['moreChanges']
                return

            if 'type' in line and line['type'] == "error":
                raise Exception(line['message'])

            change = ModelChange.from_json(line)
            # Old gerrit sets 'sortKey'
            if "sortKey" in line:
                c.sortkey = line["sortKey"]
            c.gotany = True
            c.count = c.count + 1
            cb(change)
Example #4
0
        def mycb(line):
            if 'rowCount' in line:
                # New gerrit sets 'moreChanges'
                if 'moreChanges' in line:
                    c.has_more = line['moreChanges']
                return

            if 'type' in line and line['type'] == "error":
                raise Exception(line['message'])

            change = ModelChange.from_json(line)
            # Old gerrit sets 'sortKey'
            if "sortKey" in line:
                c.sortkey = line["sortKey"]
            c.gotany = True
            c.count = c.count + 1
            cb(change)
Example #5
0
    def test_json_parse(self):
        change = ModelChange.from_json(json.loads(JSON_CHANGE))

        self.assertEquals(type(change), ModelChange)

        self.assertEquals(change.project, "openstack/nova-specs")
        self.assertEquals(change.branch, "master")
        self.assertEquals(change.number, 85556)
        self.assertEquals(change.subject, "Libvirt-Enable suppport for discard option for disk device")
        self.assertEquals(change.url, "https://review.openstack.org/85556")
        self.assertEquals(change.createdOn, 1396715237)
        self.assertEquals(change.lastUpdated, 1397487650)
        self.assertEquals(change.status, "NEW")

        self.assertEquals(type(change.owner), ModelUser)
        self.assertEquals(change.owner.name, "boh.ricky")
        self.assertEquals(change.owner.username, "boh.ricky")
        self.assertEquals(change.owner.email, "*****@*****.**")

        self.assertEquals(len(change.patches), 2)
        self.assertEquals(change.patches[0].number, 1)
        self.assertEquals(change.patches[0].revision, "b2bc7a9f5feab51b61fc9c7725251868e998703d")
        self.assertEquals(change.patches[0].ref, "refs/changes/56/85556/1")
        self.assertEquals(change.patches[0].createdOn, 1396715237)

        self.assertEquals(type(change.patches[0].uploader), ModelUser)
        self.assertEquals(change.patches[0].uploader.name, "boh.ricky")
        self.assertEquals(change.patches[0].uploader.username, "boh.ricky")
        self.assertEquals(change.patches[0].uploader.email, "*****@*****.**")

        self.assertEquals(len(change.patches[0].approvals), 1)
        self.assertEquals(type(change.patches[0].approvals[0]), ModelApproval)
        self.assertEquals(change.patches[0].approvals[0].action, ModelApproval.ACTION_VERIFIED)
        self.assertEquals(change.patches[0].approvals[0].description, "Verified")
        self.assertEquals(change.patches[0].approvals[0].value, -1)
        self.assertEquals(change.patches[0].approvals[0].grantedOn, 1396715281)

        self.assertEquals(type(change.patches[0].approvals[0].user), ModelUser)
        self.assertEquals(change.patches[0].approvals[0].user.name, "Jenkins")
        self.assertEquals(change.patches[0].approvals[0].user.username, "jenkins")