Esempio n. 1
0
    def test_save_state_sets_nothing_if_no_previous_state(self):
        # Save the values to Redis
        self.monitor.save_state()

        # Assert
        key = Keys.get_github_releases(self.repo_name)
        self.assertIsNone(self.redis.get_int(key))
Esempio n. 2
0
 def load_state(self) -> None:
     # If Redis is enabled, restore any previously stored number of releases
     if self.redis_enabled:
         key = Keys.get_github_releases(self.repo_name)
         self._prev_no_of_releases = self.redis.get_int(key, None)
         self.logger.debug('Restored github monitor state: %s=%s', key,
                           self._prev_no_of_releases)
Esempio n. 3
0
    def test_save_state_sets_values_to_current_values(self):
        # Set monitor values manually
        self.monitor._prev_no_of_releases = 10

        # Save the values to Redis
        self.monitor.save_state()

        # Assert
        key = Keys.get_github_releases(self.repo_name)
        self.assertEqual(10, self.redis.get_int(key))
Esempio n. 4
0
    def test_load_state_sets_values_to_saved_values(self):
        # Set Redis values manually
        key = Keys.get_github_releases(self.repo_name)
        self.redis.set_unsafe(key, 10)

        # Load the values from Redis
        self.monitor.load_state()

        # Assert
        self.assertEqual(10, self.monitor._prev_no_of_releases)
Esempio n. 5
0
    def save_state(self) -> None:
        # If Redis is enabled, save the currently known number of releases
        if self.redis_enabled:
            if self._prev_no_of_releases is None:
                self.logger.debug('Skipping github monitor state save '
                                  'due to None previous number of releases.')
                return

            key = Keys.get_github_releases(self.repo_name)
            self.logger.debug('Saving github monitor state: %s=%s', key,
                              self._prev_no_of_releases)
            self.redis.set(key, self._prev_no_of_releases)