Esempio n. 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))
Esempio n. 2
0
 def test_version_info(self):
     self.assertEqual(
         set(),
         upgrader2.VersionInfo(self.version_none, {}).all_versions,
     )
     self.assertEqual(
         {self.version_a},
         upgrader2.VersionInfo(
             self.version_a,
             {},
         ).all_versions,
     )
     self.assertEqual(
         {self.version_a},
         upgrader2.VersionInfo(
             self.version_none,
             {
                 self.version_a,
             },
         ).all_versions,
     )
     self.assertEqual(
         {self.version_a},
         upgrader2.VersionInfo(
             self.version_a,
             {},
         ).all_versions,
     )
     self.assertEqual(
         {self.version_a, self.version_b},
         upgrader2.VersionInfo(
             self.version_a,
             {self.version_b},
         ).all_versions,
     )
     self.assertEqual(
         {self.version_a, self.version_b},
         upgrader2.VersionInfo(
             self.version_a,
             {self.version_a, self.version_b},
         ).all_versions,
     )
Esempio n. 3
0
 async def get_versions(self) -> upgrader2.VersionInfo:
     return upgrader2.VersionInfo(
         current_version=self.current_version,
         available_versions=self.installed_versions,
     )