def test_remove_older(self): """ Run remove older on testcases repository. """ self._remove_older(self.REPO, '1') self.assertStatus(200) # Get current user user = self.app.userdb.get_user(self.USERNAME) repo = user.get_repo(self.REPO) # Run the job. p = RemoveOlder(cherrypy.engine, self.app) p._remove_older(user, repo, 30) # Check number of history. r = librdiff.RdiffRepo(user.user_root, repo.name) self.assertEqual(2, len(r.get_history_entries()))
def test_remove_older(self): """ Run remove older on testcases repository. """ self._remove_older('admin', 'testcases', '1') self.assertStatus(200) # Get current user user = self.app.store.get_user(self.USERNAME) repo = user.get_repo(self.REPO) repo.keepdays = 30 # Run the job. p = RemoveOlder(cherrypy.engine, self.app) p._remove_older(repo) # Check number of history. repo = user.get_repo(self.REPO) self.assertEqual(2, len(repo.get_history_entries()))
def test_job_run_without_keepdays(self): """ Test execution of job run. """ # Mock the call to _remove_older to make verification. p = RemoveOlder(cherrypy.engine, self.app) p._remove_older = MagicMock() # Call the job. p.job_run() # Check if _remove_older was called p._remove_older.assert_not_called()
def test_job_run_with_keepdays(self): """ Test execution of job run. """ # Mock the call to _remove_older to make verification. p = RemoveOlder(cherrypy.engine, self.app) p._remove_older = MagicMock() # Set a keepdays user = self.app.userdb.get_user(self.USERNAME) repo = user.get_repo(self.REPO) repo.keepdays = 30 # Call the job. p.job_run() # Check if _remove_older was called p._remove_older.assert_called_once_with(user, repo, 30)