def announce_await_push(test_suite, release, wait=0.1): irc.announce(release) test_suite.assertTrue( backends.push_done.wait(timeout=5), "Backend pushes never completed" ) backends.push_done.clear() time.sleep(wait)
def test_no_snatch(self): release = Release( messages=[ "Old: multi title", "Category: color tree fruit;", "PATH: https://example/f?id=12345", ], channel=channel, title="multi title", url="http://example/dl.php/12345/config_string/multi+title.jpg", indexer="Multi", backends=config.backends.keys(), ) irc.announce(release, wait=0.5) backends.max_announcements(self, "my_sonarr", 0) backends.max_announcements(self, "my_radarr", 0) backends.max_announcements(self, "my_lidarr", 0) self.assertEqual(db.nr_announcements(), 0) self.assertEqual(db.nr_snatches(), 0) irc.announce(release, wait=0.5) backends.max_announcements(self, "my_sonarr", 0) backends.max_announcements(self, "my_radarr", 0) backends.max_announcements(self, "my_lidarr", 0) self.assertEqual(db.nr_announcements(), 0) self.assertEqual(db.nr_snatches(), 0) misc.announce_await_push(self, release) backends.check_first_rx( self, config.backends["my_sonarr"], release, ) backends.check_first_rx( self, config.backends["my_radarr"], release, ) backends.check_first_rx( self, config.backends["my_lidarr"], release, ) self.assertEqual(db.nr_announcements(), 1) self.assertEqual(db.nr_snatches(), 0) misc.check_announced( self, config, release, )
def test_all_variables_missing(self): release = Release( messages=["test - test"], channel=channel, ) irc.announce(release, wait=1) backends.max_announcements(self, "line_sonarr", 0) backends.max_announcements(self, "line_radarr", 0) backends.max_announcements(self, "line_lidarr", 0) self.assertEqual(db.nr_announcements(), 0) self.assertEqual(db.nr_snatches(), 0)
def test_missing_torrent_url(self): release = Release( messages=["tags: tag1||tag2 - extractone: SetRegex : ; 2"], channel=channel, ) irc.announce(release, wait=1) backends.max_announcements(self, "line_sonarr", 0) backends.max_announcements(self, "line_radarr", 0) backends.max_announcements(self, "line_lidarr", 0) self.assertEqual(db.nr_announcements(), 0) self.assertEqual(db.nr_snatches(), 0)
def test_no_match(self): release = Release( messages=[ "this is a name - cow/ ¤/(- #angry# - pasta and sauce" ], channel=channel, ) irc.announce(release, wait=1) backends.max_announcements(self, "my_sonarr", 0) backends.max_announcements(self, "my_radarr", 0) backends.max_announcements(self, "my_lidarr", 0) self.assertEqual(db.nr_announcements(), 0) self.assertEqual(db.nr_snatches(), 0)
def test_no_snatch(self): release = Release( messages=["title 1 - stuff 1"], channel=channel, title="title 1", url="stuff: stuff 1", indexer="Delay", backends=config.backends.keys(), ) irc.announce(release) time.sleep(7) backends.max_announcements(self, "delayed_sonarr", 0) backends.max_announcements(self, "delayed_radarr", 0) backends.max_announcements(self, "delayed_lidarr", 0) time.sleep(2) backends.check_first_rx( self, config.backends["delayed_sonarr"], release, ) backends.check_first_rx( self, config.backends["delayed_radarr"], release, ) backends.check_first_rx( self, config.backends["delayed_lidarr"], release, ) self.assertEqual(db.nr_announcements(), 1) self.assertEqual(db.nr_snatches(), 0) misc.check_announced( self, config, release, )
def test_non_capture_with_match(self): release = Release( messages=[ "Old: some title", "Category: color tree fruit; misc stuff", "PATH: https://example/f?id=1357", ], channel=channel, title="some title", url="http://example/dl.php/1357/config_string/some+title.jpg", indexer="Multi", backends=config.backends.keys(), ) irc.announce(release) irc.announce(release) misc.announce_await_push(self, release) backends.check_first_rx( self, config.backends["my_sonarr"], release, ) backends.check_first_rx( self, config.backends["my_radarr"], release, ) backends.check_first_rx( self, config.backends["my_lidarr"], release, ) self.assertEqual(db.nr_announcements(), 1) self.assertEqual(db.nr_snatches(), 0) misc.check_announced( self, config, release, )
def test_database_transaction_error(self): release = Release( messages=["database transaction title : some stuff"], channel=channel, title="database transaction", url="smth: some stuff", indexer="Simple1", backends=config.backends.keys(), ) # Trigger database error by moving the db file os.rename("data/brain.db", "data/brain.db.tmp") irc.announce(release, wait=1) os.rename("data/brain.db.tmp", "data/brain.db") backends.max_announcements(self, "MySonarr", 0) backends.max_announcements(self, "MyRadarr", 0) backends.max_announcements(self, "MyLidarr", 0) self.assertEqual(db.nr_announcements(), 0) self.assertEqual(db.nr_snatches(), 0)
def test_sonarr_snatch(self): release = Release( messages=[ "Old: second multi ", "Category: color;", "PATH: https://example/a?id=54321", ], channel=channel, title="second multi", url="http://example/dl.php/54321/config_string/second+multi.jpg", indexer="Multi", backends=["my_sonarr"], snatches=["my_sonarr"], ) backends.send_approved("my_sonarr", True) irc.announce(release) irc.announce(release) misc.announce_await_push(self, release) backends.check_first_rx( self, config.backends["my_sonarr"], release, ) backends.max_announcements(self, "my_radarr", 0) backends.max_announcements(self, "my_lidarr", 0) self.assertEqual(db.nr_announcements(), 1) self.assertEqual(db.nr_snatches(), 1) misc.check_announced( self, config, release, )
def test_renotify_lidarr(self): release = Release( messages=[ "Old: third ", "Category: fruit;", "PATH: https://ex/a?id=99" ], channel=channel, title="third", url="http://ex/dl.php/99/config_string/third.jpg", indexer="Multi", backends=["my_radarr"], snatches=["my_radarr"], ) backends.send_approved("my_radarr", True) irc.announce(release) irc.announce(release) misc.announce_await_push(self, release) backends.check_first_rx( self, config.backends["my_radarr"], release, ) backends.max_announcements(self, "my_sonarr", 0) backends.max_announcements(self, "my_lidarr", 0) self.assertEqual(db.nr_announcements(), 1) self.assertEqual(db.nr_snatches(), 1) misc.check_announced( self, config, release, ) backends.send_approved("my_lidarr", True) browser.renotify(self, config, table_row=1, backend="my_sonarr", success=False) browser.renotify(self, config, table_row=1, backend="my_radarr", success=False) browser.renotify(self, config, table_row=1, backend="my_lidarr", success=True) release.snatches.append("my_lidarr") backends.check_first_rx( self, config.backends["my_lidarr"], release, ) backends.max_announcements(self, "my_sonarr", 1) backends.max_announcements(self, "my_radarr", 1) self.assertEqual(db.nr_announcements(), 1) self.assertEqual(db.nr_snatches(), 2) misc.check_announced( self, config, release, )