def test_get_actions(self): """ Test get actions """ test_cases = { None: [], '': [], 'wrong': [], 'downloaded': Quality.DOWNLOADED, 'Downloaded': Quality.DOWNLOADED, 'snatched': Quality.SNATCHED, 'Snatched': Quality.SNATCHED, } unicode_test_cases = { u'': [], u'wrong': [], u'downloaded': Quality.DOWNLOADED, u'Downloaded': Quality.DOWNLOADED, u'snatched': Quality.SNATCHED, u'Snatched': Quality.SNATCHED, } for tests in test_cases, unicode_test_cases: for (action, result) in tests.iteritems(): self.assertEqual(History._get_actions(action), result) # pylint: disable=protected-access
def test_get_limit(self): """ Test get limit """ test_cases = { None: 0, '': 0, '0': 0, '5': 5, '-5': 0, '1.5': 0, '-1.5': 0, 5: 5, -5: 0, 1.5: 1, -1.5: 0, } unicode_test_cases = { u'': 0, u'0': 0, u'5': 5, u'-5': 0, u'1.5': 0, u'-1.5': 0, } for tests in test_cases, unicode_test_cases: for (action, result) in tests.iteritems(): self.assertEqual(History._get_limit(action), result) # pylint: disable=protected-access
def test_get_limit(self): """ Tests the static get limit method which should return the limit on the amount of elements that should be shown/returned """ test_cases = { None: 0, '': 0, '0': 0, '5': 5, '-5': 0, '1.5': 0, '-1.5': 0, 5: 5, -5: 0, 1.5: 1, -1.5: 0, } unicode_test_cases = { '': 0, '0': 0, '5': 5, '-5': 0, '1.5': 0, '-1.5': 0, } for tests in test_cases, unicode_test_cases: for (action, result) in six.iteritems(tests): self.assertEqual(History._get_limit(action), result) # pylint: disable=protected-access
def test_get_actions(self): """ Tests whether or not the different kinds of actions an episode can have are returned correctly """ test_cases = { None: [], '': [], 'wrong': [], 'downloaded': Quality.DOWNLOADED, 'Downloaded': Quality.DOWNLOADED, 'snatched': Quality.SNATCHED, 'Snatched': Quality.SNATCHED, } unicode_test_cases = { '': [], 'wrong': [], 'downloaded': Quality.DOWNLOADED, 'Downloaded': Quality.DOWNLOADED, 'snatched': Quality.SNATCHED, 'Snatched': Quality.SNATCHED, } for tests in test_cases, unicode_test_cases: for (action, result) in six.iteritems(tests): self.assertEqual(History._get_actions(action), result) # pylint: disable=protected-access
class History(WebRoot): def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) self.history = HistoryTool() def index(self, limit=None): if limit is None: if sickbeard.HISTORY_LIMIT: limit = int(sickbeard.HISTORY_LIMIT) else: limit = 100 else: limit = try_int(limit, 100) sickbeard.HISTORY_LIMIT = limit sickbeard.save_config() history = self.history.get(limit) t = PageTemplate(rh=self, filename='history.mako') submenu = [ {'title': 'Clear History', 'path': 'history/clearHistory', 'icon': 'ui-icon ui-icon-trash', 'class': 'clearhistory', 'confirm': True}, {'title': 'Trim History', 'path': 'history/trimHistory', 'icon': 'menu-icon-cut', 'class': 'trimhistory', 'confirm': True}, ] return t.render(historyResults=history.detailed, compactResults=history.compact, limit=limit, submenu=submenu, title='History', header='History', topmenu='history', controller='history', action='index') def clearHistory(self): self.history.clear() ui.notifications.message('History cleared') return self.redirect('/history/') def trimHistory(self): self.history.trim() ui.notifications.message('Removed history entries older than 30 days') return self.redirect('/history/')
def test_get_actions(self): tests = { None: [], '': [], u'': [], 'wrong': [], u'wrong': [], 'downloaded': Quality.DOWNLOADED, u'downloaded': Quality.DOWNLOADED, 'Downloaded': Quality.DOWNLOADED, u'Downloaded': Quality.DOWNLOADED, 'snatched': Quality.SNATCHED, u'snatched': Quality.SNATCHED, 'Snatched': Quality.SNATCHED, u'Snatched': Quality.SNATCHED, } for (action, result) in tests.iteritems(): self.assertEqual(History._get_actions(action), result)
def test_get_limit(self): tests = { None: 0, '': 0, u'': 0, '0': 0, u'0': 0, '5': 5, u'5': 5, '-5': 0, u'-5': 0, '1.5': 0, u'1.5': 0, '-1.5': 0, u'-1.5': 0, 5: 5, -5: 0, 1.5: 1, -1.5: 0, } for (action, result) in tests.iteritems(): self.assertEqual(History._get_limit(action), result)
def __init__(self, *args, **kwargs): super(History, self).__init__(*args, **kwargs) self.history = HistoryTool()