Esempio n. 1
0
    def test_dag_default_args_owner_validation(self):
        with pytest.raises(ValueError):
            assert DagDefaultArgs(owner="invalid_email", start_date="2020-12-12")

        with pytest.raises(ValueError):
            assert DagDefaultArgs(owner="test@example-com.", start_date="2020-12-12")

        with pytest.raises(TypeError):
            assert DagDefaultArgs(owner=None, start_date="2020-12-12")

        assert DagDefaultArgs(owner="*****@*****.**", start_date="2020-12-12")
Esempio n. 2
0
    def test_dag_default_args_start_date_validation(self):
        with pytest.raises(ValueError):
            assert DagDefaultArgs(
                owner="*****@*****.**", start_date="March 12th 2020"
            )

        with pytest.raises(ValueError):
            assert DagDefaultArgs(owner="*****@*****.**", start_date="foo")

        with pytest.raises(ValueError):
            assert DagDefaultArgs(owner="*****@*****.**", start_date="2020-13-01")

        assert DagDefaultArgs(owner="*****@*****.**", start_date="2020-12-12")
Esempio n. 3
0
    def test_public_data_json_dag_add_task(self):
        public_json_dag = PublicDataJsonDag("bqetl_public_data_json_dag",
                                            "daily", self.default_args)

        assert len(public_json_dag.tasks) == 0

        query_file = (TEST_DIR / "data" / "test_sql" /
                      "moz-fx-data-test-project" / "test" /
                      "incremental_query_v1" / "query.sql")

        task = Task.of_query(query_file)
        dag = Dag(
            "bqetl_events",
            "0 1 * * *",
            DagDefaultArgs("*****@*****.**", "2020-01-01"),
            [task],
        )
        public_json_dag.add_export_tasks([task], DagCollection([dag]))

        assert len(public_json_dag.tasks) == 1
        assert (public_json_dag.tasks[0].task_name ==
                "export_public_data_json_test__incremental_query__v1")
        assert public_json_dag.tasks[
            0].dag_name == "bqetl_public_data_json_dag"
        assert len(public_json_dag.tasks[0].dependencies) == 1
Esempio n. 4
0
    def test_dag_default_args_email_validation(self):
        with pytest.raises(ValueError):
            assert DagDefaultArgs(
                owner="*****@*****.**",
                start_date="2020-12-12",
                email=["*****@*****.**", "invalid", "*****@*****.**"],
            )

        assert DagDefaultArgs(owner="*****@*****.**",
                              start_date="2020-12-12",
                              email=[])

        assert DagDefaultArgs(
            owner="*****@*****.**",
            start_date="2020-12-12",
            email=["*****@*****.**", "*****@*****.**"],
        )
Esempio n. 5
0
    def test_dag_default_args_retry_delay_validation(self):
        with pytest.raises(ValueError):
            assert DagDefaultArgs(owner="*****@*****.**",
                                  start_date="2020-12-12",
                                  retry_delay="90")

        with pytest.raises(ValueError):
            assert DagDefaultArgs(owner="*****@*****.**",
                                  start_date="2020-12-12",
                                  retry_delay="1d1h1m")

        assert DagDefaultArgs(owner="*****@*****.**",
                              start_date="2020-12-12",
                              retry_delay="3h15m1s")

        assert DagDefaultArgs(owner="*****@*****.**",
                              start_date="2020-12-12",
                              retry_delay="3h")
Esempio n. 6
0
 def test_empty_dag_default_args(self):
     with pytest.raises(TypeError):
         assert DagDefaultArgs()