コード例 #1
0
ファイル: test_advisory.py プロジェクト: pulp/pulp_rpm
    def test_same_dates_empty_intersection(self):
        """
        Case 1: Same date, pkglist intersection empty.

        Merge into existing, added[] = existing, excluded[] = incoming.
        """
        urs = UpdateRecordSerializer()
        cbd_data = json.loads(CAMEL_BEAR_DOG_JSON)
        existing = urs.create(cbd_data)

        b_data = json.loads(BIRD_JSON)
        incoming = urs.create(b_data)
        try:
            added, removed, excluded = resolve_advisory_conflict(
                existing, incoming)
            self.assertIsNotNone(added)
            self.assertIsNotNone(excluded)
            self.assertEqual(1, len(added))
            self.assertEqual(1, len(excluded))
            self.assertEqual(1, len(removed))
            self.assertEqual(existing.pulp_id, added[0])
            self.assertEqual(incoming.pulp_id, excluded[0])
            self.assertIsNotNone(existing.get_pkglist())
            names = set([pkg[0] for pkg in existing.get_pkglist()])
            for name in ("camel", "bear", "dog", "bird"):
                self.assertIn(name, names)
        finally:
            existing.delete()
            incoming.delete()
コード例 #2
0
ファイル: test_advisory.py プロジェクト: pulp/pulp_rpm
    def test_diff_dates_name_intersection(self):
        """
        Case 3a: Dates differ, pkglist intersection empty, pkglists differ ONLY by EVR (same names).

        Accept "newer", remove/exclude "older"
        """
        urs = UpdateRecordSerializer()
        b_data = json.loads(BIRD_JSON)
        existing1 = urs.create(b_data)

        nb_data = json.loads(NEW_BIRD_JSON)
        nb_data["version"] = "3"
        incoming3 = urs.create(nb_data)

        b_data = json.loads(BIRD_JSON)
        b_data["version"] = "4"
        existing4 = urs.create(b_data)

        try:
            # incoming newer
            added, removed, excluded = resolve_advisory_conflict(
                existing1, incoming3)
            self.assertEqual(0, len(added))
            self.assertEqual(0, len(excluded))
            self.assertEqual(1, len(removed))
            self.assertEqual(existing1.pulp_id, removed[0])

            # existing newer
            added, removed, excluded = resolve_advisory_conflict(
                existing4, incoming3)
            self.assertEqual(0, len(added))
            self.assertEqual(1, len(excluded))
            self.assertEqual(0, len(removed))
            self.assertEqual(incoming3.pulp_id, excluded[0])
        finally:
            existing1.delete()
            existing4.delete()
            incoming3.delete()
コード例 #3
0
ファイル: test_advisory.py プロジェクト: pulp/pulp_rpm
    def test_diff_dates_nonempty_intersection(self):
        """
        Case 2: Dates different, pkglist intersection non-empty.

        Accept "newer", remove/exclude "older"
        """
        urs = UpdateRecordSerializer()
        cb_data = json.loads(CAMEL_BEAR_JSON)
        existing1 = urs.create(cb_data)

        cbd_data = json.loads(CAMEL_BEAR_DOG_JSON)
        cbd_data["version"] = "2"
        incoming2 = urs.create(cbd_data)

        cb_data = json.loads(CAMEL_BEAR_JSON)
        cb_data["version"] = "3"
        existing3 = urs.create(cb_data)
        try:
            # Incoming is newer
            added, removed, excluded = resolve_advisory_conflict(
                existing1, incoming2)
            self.assertEqual(0, len(added))
            self.assertEqual(0, len(excluded))
            self.assertEqual(1, len(removed))
            self.assertEqual(existing1.pulp_id, removed[0])

            # Existing is newer
            added, removed, excluded = resolve_advisory_conflict(
                existing3, incoming2)
            self.assertEqual(0, len(added))
            self.assertEqual(1, len(excluded))
            self.assertEqual(0, len(removed))
            self.assertEqual(incoming2.pulp_id, excluded[0])
        finally:
            existing1.delete()
            existing3.delete()
            incoming2.delete()
コード例 #4
0
ファイル: test_advisory.py プロジェクト: pulp/pulp_rpm
    def test_same_dates_nonempty_intersection(self):
        """
        Case 4: Same dates, pkglist intersection not empty, intersection NOT subset of either.

        Raise ERROR
        """
        urs = UpdateRecordSerializer()
        cb_data = json.loads(CAMEL_BEAR_BIRD_JSON)
        existing = urs.create(cb_data)

        cbd_data = json.loads(CAMEL_BEAR_DOG_JSON)
        incoming = urs.create(cbd_data)
        try:
            with self.assertRaises(AdvisoryConflict):
                added, removed, excluded = resolve_advisory_conflict(
                    existing, incoming)
        finally:
            existing.delete()
            incoming.delete()
コード例 #5
0
ファイル: test_advisory.py プロジェクト: pulp/pulp_rpm
    def test_diff_dates_empty_intersection(self):
        """
        Case 3b: Dates differ, pkglist intersection empty, NOT same pkg-names.

        raise ERROR
        """
        urs = UpdateRecordSerializer()
        cb_data = json.loads(CAMEL_BEAR_JSON)
        cb_data["version"] = "3"
        incoming3 = urs.create(cb_data)

        b_data = json.loads(BIRD_JSON)
        existing = urs.create(b_data)
        try:
            with self.assertRaises(AdvisoryConflict):
                added, removed, excluded = resolve_advisory_conflict(
                    existing, incoming3)
        finally:
            existing.delete()
            incoming3.delete()