示例#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,
        )
示例#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"],
        )
示例#3
0
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,
        )
示例#4
0
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,
        )