def test_start_invalid_repo(self): with database.session_scope() as session: session.add(util.create_repo({"repo.invalid": True})) session.add(util.create_channel(dict())) self.crawler.start() time.sleep(3) with database.session_scope() as session: commits = session.query(database.Commit).all() self.assertEqual(len(commits), 0)
def test_start_repo_and_channel_no_match(self): with database.session_scope() as session: session.add(util.create_repo(dict())) session.add(util.create_channel({"channel.branch": "maste"})) self.crawler.start() time.sleep(5) called = self.crawler.query( lambda: self.scheduler.process_commits.called) self.assertFalse(called)
def test_start_repo_and_regex_channel(self): with database.session_scope() as session: session.add(util.create_repo(dict())) session.add(util.create_channel({"channel.branch": "mas.*"})) self.crawler.start() time.sleep(5) called = self.crawler.query( lambda: self.scheduler.process_commits.called) self.assertTrue(called) with database.session_scope() as session: commit = session.query(database.Commit).first() self.assertEqual(database.CommitStatus.new, commit.status)
def test_http_repo(self): with database.session_scope() as session: session.add(util.create_repo({"repo.https": True})) session.add(util.create_channel(dict())) self.crawler.start() time.sleep(5) called = self.crawler.query( lambda: self.scheduler.process_commits.called) self.assertTrue(called) with database.session_scope() as session: commit = session.query(database.Commit).first() self.assertEqual(database.CommitStatus.new, commit.status)