Exemplo n.º 1
0
    def test_compare_dict_blobs_default(self):
        """
        Test default values for comparisson of git blob dictionaries
        """
        from oe.buildhistory_analysis import compare_dict_blobs
        defaultmap = {
            x: ("default", "1")
            for x in ["PKG", "PKGE", "PKGV", "PKGR"]
        }

        self.commit_vars(to_add={"foo": "1"})
        blob1 = self.repo.heads.master.commit.tree.blobs[0]

        self.commit_vars(to_add={
            "PKG": "1",
            "PKGE": "1",
            "PKGV": "1",
            "PKGR": "1"
        })
        blob2 = self.repo.heads.master.commit.tree.blobs[0]

        change_records = compare_dict_blobs(
            os.path.join(self.repo_path, self.test_file), blob1, blob2, False,
            False)

        var_changes = {}
        for x in change_records:
            oldvalue = "default" if ("default" in x.oldvalue) else x.oldvalue
            var_changes[x.fieldname] = (oldvalue, x.newvalue)

        self.assertEqual(defaultmap, var_changes, "Defaults not set properly")
Exemplo n.º 2
0
    def test_compare_dict_blobs(self):
        """
        Test comparisson of dictionaries extracted from git blobs
        """
        from oe.buildhistory_analysis import compare_dict_blobs

        changesmap = {
            "foo-2": ("2", "8"),
            "bar": ("", "4"),
            "bar-2": ("", "5")
        }

        self.commit_vars(to_add={"foo": "1", "foo-2": "2", "foo-3": "3"})
        blob1 = self.repo.heads.master.commit.tree.blobs[0]

        self.commit_vars(to_add={"foo-2": "8", "bar": "4", "bar-2": "5"})
        blob2 = self.repo.heads.master.commit.tree.blobs[0]

        change_records = compare_dict_blobs(
            os.path.join(self.repo_path, self.test_file), blob1, blob2, False,
            False)

        var_changes = {
            x.fieldname: (x.oldvalue, x.newvalue)
            for x in change_records
        }
        self.assertEqual(changesmap, var_changes,
                         "Changes not reported correctly")
Exemplo n.º 3
0
    def test_compare_dict_blobs(self):
        """
        Test comparisson of dictionaries extracted from git blobs
        """
        changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")}

        self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" })
        blob1 = self.repo.heads.master.commit.tree.blobs[0]

        self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" })
        blob2 = self.repo.heads.master.commit.tree.blobs[0]

        change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file),
            blob1, blob2, False, False)

        var_changes = { x.fieldname : (x.oldvalue, x.newvalue) for x in change_records}
        self.assertEqual(changesmap, var_changes, "Changes not reported correctly")
Exemplo n.º 4
0
    def test_compare_dict_blobs_default(self):
        """
        Test default values for comparisson of git blob dictionaries
        """
        defaultmap = { x : ("default", "1")  for x in ["PKG", "PKGE", "PKGV", "PKGR"]}

        self.commit_vars(to_add = { "foo" : "1" })
        blob1 = self.repo.heads.master.commit.tree.blobs[0]

        self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" })
        blob2 = self.repo.heads.master.commit.tree.blobs[0]

        change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file),
            blob1, blob2, False, False)

        var_changes = {}
        for x in change_records:
            oldvalue = "default" if ("default" in x.oldvalue) else x.oldvalue
            var_changes[x.fieldname] = (oldvalue, x.newvalue)

        self.assertEqual(defaultmap, var_changes, "Defaults not set properly")