Beispiel #1
0
def test_query_rejects_empty_datasource_name():
    with pytest.raises(domain.exceptions.InvalidJobSpecException):
        domain.Job(
            report_name="Customers",
            sql_file="/tmp/test.sql",
            datasource_name="",
            height=200,
            seconds_between_refreshes=100,
        )
Beispiel #2
0
def load(*, path: pathlib.Path) -> PyodbcConfig:
    with path.open("r") as fh:
        data = json.load(fh)

        datasources = [domain.Datasource(**ds) for ds in data["datasources"]]

        jobs = [domain.Job(**ds) for ds in data["jobs"]]

        return PyodbcConfig(
            datasources=datasources,
            jobs=jobs,
            reports_per_row=data["reports_per_row"],
        )
def test_empty_datasources():
    with pytest.raises(domain.exceptions.InvalidConfigurationSetting):
        domain.Config(
            datasources=[],
            jobs=[
                domain.Job(
                    report_name="Test Report",
                    sql_file="./test_report.sql",
                    datasource_name="test_datasource",
                    seconds_between_refreshes=60,
                    height=200,
                ),
            ],
            reports_per_row=3,
        )
def test_negative_reports_per_row():
    with pytest.raises(domain.exceptions.InvalidConfigurationSetting):
        domain.Config(
            datasources=[
                domain.Datasource(
                    name="localhost",
                    uri=
                    "postgresql+psycopg2://test:mypassword@localhost/testdb",
                ),
            ],
            jobs=[
                domain.Job(
                    report_name="Test Report",
                    sql_file="./test_report.sql",
                    datasource_name="test_datasource",
                    seconds_between_refreshes=60,
                    height=200,
                ),
            ],
            reports_per_row=-1,
        )