コード例 #1
0
    def test_base(self, project):

        # seed command
        results = run_dbt(["seed"])
        # seed result length
        assert len(results) == 1

        # run command
        results = run_dbt()
        # run result length
        assert len(results) == 3

        # names exist in result nodes
        check_result_nodes_by_name(results, ["view_model", "table_model", "swappable"])

        # check relation types
        expected = {
            "base": "materializedview",
            "view_model": "view",
            "table_model": "materializedview",
            "swappable": "materializedview",
        }
        check_relation_types(project.adapter, expected)

        # base table rowcount
        relation = relation_from_name(project.adapter, "base")
        result = project.run_sql(
            f"select count(*) as num_rows from {relation}", fetch="one"
        )
        assert result[0] == 10

        # relations_equal
        check_relations_equal(
            project.adapter, ["base", "view_model", "table_model", "swappable"]
        )

        # check relations in catalog
        catalog = run_dbt(["docs", "generate"])
        assert len(catalog.nodes) == 4
        assert len(catalog.sources) == 1

        # run_dbt changing materialized_var to view
        results = run_dbt(
            ["run", "-m", "swappable", "--vars", "materialized_var: view"]
        )
        assert len(results) == 1

        # check relation types, swappable is view
        expected = {
            "base": "materializedview",
            "view_model": "view",
            "table_model": "materializedview",
            "swappable": "view",
        }
        check_relation_types(project.adapter, expected)
コード例 #2
0
    def test_store_failures(self, project):
        # run models
        results = run_dbt(["run"])
        # run result length
        assert len(results) == 1

        results = run_dbt(["test"], expect_pass=False)  # expect failing test
        assert len(results) == 2

        result_statuses = sorted(r.status for r in results)
        assert result_statuses == ["fail", "pass"]
コード例 #3
0
    def test_custom_materializations(self, project):
        # seed seeds
        results = run_dbt(["seed"])
        # seed result length
        assert len(results) == 1
        # run models
        results = run_dbt(["run"])
        # run result length
        # assert len(results) == 8 todo: re-enable once #14195 lands
        assert len(results) == 7

        # relations_equal
        check_relations_equal(
            project.adapter, ["test_materialized_view", "test_view_index"]
        )

        check_relations_equal(project.adapter, ["actual_indexes", "expected_indexes"])
コード例 #4
0
 def test_build_assert_equal(self, project):
     run_dbt(['deps'])
     run_dbt(['build'])  # seed, model, test -- all handled by dbt
コード例 #5
0
 def test_build_assert_equal(self, project):
     run_dbt(['deps'])
     super().test_build_assert_equal(project)