def test_retrieve(database): gh = github3.login("user", "name") conn, Session = database recorder = betamax.Betamax(gh._session) with recorder.use_cassette("simple_pr_request"): repo = gh.repository("Python", "cpython") pr_object = repo.pull_request(1) with session_scope(Session()) as session: new_pr = create_pull_request_from_gh_object(pr_object) session.add(new_pr) prs, = *conn.execute("SELECT * from pull_requests"), assert prs.number == 1
def main(): gh = github3.login(os.getenv("BOT_MAIL"), os.getenv("BOT_PASSWORD")) engine, Base, Session = init_db() repo = gh.repository("Python", "cpython") with session_scope(Session()) as session: while True: update_core_devs(gh, session) get_latest_pr_from_github(repo, session) update_open_prs(repo, session) next_date = datetime.datetime.now() + datetime.timedelta(days=1) logger.info(f"Schedulling next check: {next_date}") time.sleep((next_date - datetime.datetime.now()).seconds)
def get_core_developers(): with session_scope(SESSION()) as session: core_devs = pd.read_sql( session.query(CoreDeveloper).statement, session.bind) return core_devs
def get_pull_requests(): with session_scope(SESSION()) as session: latest_prs = pd.read_sql( session.query(PullRequest).statement, session.bind) return latest_prs