Exemple #1
0
def test_shows_tomorrow(test_client, test_session, fake_redis):

    response = test_client.get('/scrape', follow_redirects=True)
    assert response.status_code == 200

    response = test_client.get('/shows', follow_redirects=True)
    soup = BeautifulSoup(response.data, 'html.parser')
    table_headers = [th.text for th in soup.find_all('th')]
    for cinema_name in cinema.showtime_scraper.cinema_ls:
        assert cinema_name in table_headers
Exemple #2
0
def test_pairwise_disjoint(test_client, test_session, test_worker, fake_redis):
    # TODO: create a database fixture instead of hitting the scrape endpoint.

    response = test_client.get('/scrape', follow_redirects=True)
    assert response.status_code == 200

    response = test_client.get('/shows/indie')
    soup = BeautifulSoup(response.data, 'html.parser')
    tables = soup.find_all('table')
    assert tables
    shows = [set([td.text for td in t.find_all('td')]) for t in tables]
    for s1, s2 in itertools.combinations(shows, 2):
        assert s1.isdisjoint(s2)
    def test_static_routes(self, test_client, test_client_static):

        rv = test_client.get("/static/images/Group.jpg")
        assert "200" in str(rv.status)

        rv = test_client_static.get("/static_copy/images/Group.jpg")
        assert "200" in str(rv.status)
Exemple #4
0
def test_scrape_endpoint_fakeredis(test_session, test_client, fake_redis):
    response = test_client.get('/scrape', follow_redirects=True)
    assert response.status_code == 200
    for cinema_name in cinema.showtime_scraper.cinema_ls:
        theater = test_session.query(Theater).filter_by(
            name=cinema_name).first()
        assert theater
        assert theater.showtimes
Exemple #5
0
def test_unsubscribe(test_client, test_db):
    test_email = '*****@*****.**'
    new_user = actions.add_user(
        test_email,
        location=actions.add_or_return_location('Montreal, Canada'))
    token = auth.generate_confirmation_token(new_user.email)

    response = test_client.get(f'unsubscribe/{token}')

    assert response.status_code == 302
    def test_api_named_routes(self, test_client):
        config = {
            "WHITE_LIST_ROUTES": [("GET", "/test222")],
            "JWT_ROUTER_API_NAME": "/api/v1",
            "DEBUG": True
        }
        test_client.config = config

        rv = test_client.get("/api/v1/test")
        assert "200" in str(rv.status)
Exemple #7
0
def test_no_duplicate_inserts(test_session, test_client, fake_redis):

    response = test_client.get('/scrape', follow_redirects=True)
    assert response.status_code == 200

    showtimes_dict = dict()
    for cinema_name in cinema.showtime_scraper.cinema_ls:
        theater = test_session.query(Theater).filter_by(
            name=cinema_name).first()
        assert theater
        assert theater.showtimes
        showtimes_dict[cinema_name] = theater.showtimes

    response = test_client.get('/scrape', follow_redirects=True)
    assert response.status_code == 200

    for cinema_name in cinema.showtime_scraper.cinema_ls:
        theater = test_session.query(Theater).filter_by(
            name=cinema_name).first()
        assert cinema_name in showtimes_dict
        assert theater.showtimes == showtimes_dict[cinema_name]
Exemple #8
0
def test_empty_db(test_client):
    rv = test_client.get('/')
    assert b'Hello!' == rv.data
Exemple #9
0
def test_app_runs(test_client):
    response = test_client.get('ping')
    assert response.status_code == 200
    assert response.data == b'pong'