Example #1
0
    def test_upgrade_intent(self):
        version_info = upgrader2.VersionInfo(
            current_version=self.version_a,
            available_versions={self.version_b, self.version_c},
        )
        intent = upgrader2.UpgradeIntent(
            stable=self.version_none, canary=self.version_none,
        )
        self.assertEqual(
            self.version_none,
            intent.version_to_prepare(version_info),
        )
        self.assertEqual(
            self.version_none, intent.version_to_force_upgrade(version_info),
        )

        # If version is already the one intended, no actions should be taken
        intent = upgrader2.UpgradeIntent(
            stable=version_info.current_version, canary=version_info.current_version,
        )

        self.assertEqual(
            self.version_none,
            intent.version_to_prepare(version_info),
        )
        self.assertEqual(
            self.version_none, intent.version_to_force_upgrade(version_info),
        )

        # If upgrade is already prepared, then no reason to prepare again
        intent = upgrader2.UpgradeIntent(
            stable=self.version_none, canary=self.version_b,
        )

        self.assertEqual(
            self.version_none,
            intent.version_to_prepare(version_info),
        )

        # Unprepared version
        intent = upgrader2.UpgradeIntent(
            stable=self.version_none, canary=self.version_d,
        )
        self.assertEqual(
            self.version_d, intent.version_to_prepare(version_info),
        )

        # Force upgrade needed
        intent = upgrader2.UpgradeIntent(
            stable=self.version_b, canary=self.version_b,
        )
        self.assertEqual(
            self.version_b, intent.version_to_force_upgrade(version_info),
        )
Example #2
0
 async def get_upgrade_intent(self) -> upgrader2.UpgradeIntent:
     return upgrader2.UpgradeIntent(stable=self.stable_version,
                                    canary=self.canary_version)