def test_scrape(setup_app): urls = URLQueue() current = urls.stack[0] @app.url_defaults def collect_urls(endpoint, values): if 'loop' in values: values.pop('loop') return urls.append(endpoint, values, current) test_app = app.test_client() while urls.stack: print(current) rv = test_app.get(current) assert rv.status_code in [200, 302] current = urls.pop() for url_values in urls.all: for filters in filter_combinations: values = url_values[1].copy() values.update(filters) with app.test_request_context(current): app.preprocess_request() url = url_for(url_values[0], **values) print(url) rv = test_app.get(url) assert rv.status_code in [200, 302]
def test_scrape(setup_app): urls = URLQueue() current = urls.stack[0] @app.url_defaults def collect_urls(endpoint, values): if 'loop' in values: values.pop('loop') return urls.append(endpoint, values, current) test_app = app.test_client() while urls.stack: print(current) rv = test_app.get(current) assert rv.status_code in [200, 302] current = urls.pop()
from fava.util.typing import LoaderResult TESTS_DIR = Path(__file__).parent def data_file(filename: str) -> str: return str(TESTS_DIR / "data" / filename) LONG_EXAMPLE_FILE = data_file("long-example.beancount") EXAMPLE_FILE = data_file("example.beancount") EXAMPLE_LEDGER = FavaLedger(LONG_EXAMPLE_FILE) fava_app.testing = True TEST_CLIENT = fava_app.test_client() fava_app.config["BEANCOUNT_FILES"] = [ LONG_EXAMPLE_FILE, EXAMPLE_FILE, data_file("extension-report-example.beancount"), data_file("import.beancount"), data_file("query-example.beancount"), ] _load_file() SNAPSHOT_UPDATE = bool(os.environ.get("SNAPSHOT_UPDATE")) MSG = "Maybe snapshots need to be updated with `SNAPSHOT_UPDATE=1 make test`?" # Keep track of multiple calls to snapshot in one test function to generate # unique (simply numbered) file names for the snashop files.
import os import pytest from beancount.loader import load_string from fava.api import BeancountReportAPI from fava.application import load_file from fava.application import app as fava_app EXAMPLE_FILE = os.path.join(os.path.dirname(__file__), 'example.beancount') API = BeancountReportAPI(EXAMPLE_FILE) fava_app.testing = True TEST_CLIENT = fava_app.test_client() fava_app.config['BEANCOUNT_FILES'] = [EXAMPLE_FILE] load_file() @pytest.fixture def app(): return fava_app @pytest.fixture def test_client(): return TEST_CLIENT @pytest.fixture