Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
usefulalgorithm committed Jul 25, 2024
1 parent 197f14b commit 3f3b432
Show file tree
Hide file tree
Showing 28 changed files with 3,367 additions and 126 deletions.
80 changes: 40 additions & 40 deletions tests/dbt/cloud/expected.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions tests/dbt/cloud/fake_graphql_server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .fake_graphql_server import endpoints

__all__ = [
"endpoints",
]
35 changes: 35 additions & 0 deletions tests/dbt/cloud/fake_graphql_server/fake_graphql_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from tests.dbt.cloud.fake_graphql_server.get_environment_adapter_type.endpoint import (
fake_GetEnvironmentAdapterType,
)
from tests.dbt.cloud.fake_graphql_server.get_job_run_macros.endpoint import (
fake_GetJobRunMacros,
)
from tests.dbt.cloud.fake_graphql_server.get_job_run_metrics.endpoint import (
fake_GetJobRunMetrics,
)
from tests.dbt.cloud.fake_graphql_server.get_job_run_models.endpoint import (
fake_GetJobRunModels,
)
from tests.dbt.cloud.fake_graphql_server.get_job_run_snapshots.endpoint import (
fake_GetJobRunSnapshots,
)
from tests.dbt.cloud.fake_graphql_server.get_job_run_sources.endpoint import (
fake_GetJobRunSources,
)
from tests.dbt.cloud.fake_graphql_server.get_job_run_tests.endpoint import (
fake_GetJobRunTests,
)
from tests.dbt.cloud.fake_graphql_server.get_macro_arguments.endpoint import (
fake_GetMacroArguments,
)

endpoints = {
"GetEnvironmentAdapterType": fake_GetEnvironmentAdapterType,
"GetJobRunMacros": fake_GetJobRunMacros,
"GetJobRunMetrics": fake_GetJobRunMetrics,
"GetJobRunModels": fake_GetJobRunModels,
"GetJobRunSnapshots": fake_GetJobRunSnapshots,
"GetJobRunSources": fake_GetJobRunSources,
"GetJobRunTests": fake_GetJobRunTests,
"GetMacroArguments": fake_GetMacroArguments,
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from typing import Any, Dict

dir_path = os.path.dirname(os.path.realpath(__file__))


def fake_GetEnvironmentAdapterType(variables: Dict[str, Any]):
with open(f"{dir_path}/jaffle_shop.json") as f:
return f.read()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"environment": {
"adapterType": "snowflake",
"dbtProjectName": "jaffle_shop"
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from typing import Any, Dict

dir_path = os.path.dirname(os.path.realpath(__file__))


def fake_GetJobRunMacros(variables: Dict[str, Any]):
with open(f"{dir_path}/jaffle_shop.json") as f:
return f.read()
1,286 changes: 1,286 additions & 0 deletions tests/dbt/cloud/fake_graphql_server/get_job_run_macros/jaffle_shop.json

Large diffs are not rendered by default.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from typing import Any, Dict

dir_path = os.path.dirname(os.path.realpath(__file__))


def fake_GetJobRunMetrics(variables: Dict[str, Any]):
with open(f"{dir_path}/jaffle_shop.json") as f:
return f.read()
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
{
"job": {
"metrics": [
{
"packageName": "jaffle_shop",
"label": "Cumulative Revenue (All Time)",
"description": "The cumulative revenue for all orders.",
"dependsOn": [
"semantic_model.jaffle_shop.order_items"
],
"uniqueId": "metric.jaffle_shop.cumulative_revenue",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "cumulative",
"sql": null,
"expression": null,
"calculation_method": "cumulative"
},
{
"packageName": "jaffle_shop",
"label": "Customers w/ Orders",
"description": "Distict count of customers placing orders",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.customers_with_orders",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Food Orders",
"description": "Count of orders that contain food order items",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.food_orders",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Food Revenue",
"description": "The revenue from food in each order",
"dependsOn": [
"semantic_model.jaffle_shop.order_items"
],
"uniqueId": "metric.jaffle_shop.food_revenue",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Food Revenue %",
"description": "The % of order revenue from food.",
"dependsOn": [
"metric.jaffle_shop.food_revenue",
"metric.jaffle_shop.revenue"
],
"uniqueId": "metric.jaffle_shop.food_revenue_pct",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "ratio",
"sql": null,
"expression": null,
"calculation_method": "ratio"
},
{
"packageName": "jaffle_shop",
"label": "Large Orders",
"description": "Count of orders with order total over 20.",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.large_order",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Locations",
"description": "Count of locations that placed in order.",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.locations",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Median Revenue",
"description": "The median revenue for each order item. Excludes tax.",
"dependsOn": [
"semantic_model.jaffle_shop.order_items"
],
"uniqueId": "metric.jaffle_shop.median_revenue",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "New Customers",
"description": "Unique count of new customers.",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.new_customer",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Order Cost",
"description": "Sum of cost for each order item.",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.order_cost",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Order Gross Profit",
"description": "Gross profit from each order.",
"dependsOn": [
"metric.jaffle_shop.order_cost",
"metric.jaffle_shop.revenue"
],
"uniqueId": "metric.jaffle_shop.order_gross_profit",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "derived",
"sql": null,
"expression": null,
"calculation_method": "derived"
},
{
"packageName": "jaffle_shop",
"label": "Orders",
"description": "Count of orders.",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.orders",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Order Total",
"description": "Sum of total order amonunt. Includes tax + revenue.",
"dependsOn": [
"semantic_model.jaffle_shop.orders"
],
"uniqueId": "metric.jaffle_shop.order_total",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Revenue",
"description": "Sum of the product revenue for each order item. Excludes tax.",
"dependsOn": [
"semantic_model.jaffle_shop.order_items"
],
"uniqueId": "metric.jaffle_shop.revenue",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "simple",
"sql": null,
"expression": null,
"calculation_method": "simple"
},
{
"packageName": "jaffle_shop",
"label": "Revenue Growth % M/M",
"description": "Percentage growth of revenue compared to 1 month ago. Excluded tax",
"dependsOn": [
"metric.jaffle_shop.revenue"
],
"uniqueId": "metric.jaffle_shop.revenue_growth_mom",
"timeGrains": [],
"timestamp": null,
"dimensions": [],
"filters": [],
"tags": [],
"type": "derived",
"sql": null,
"expression": null,
"calculation_method": "derived"
}
]
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from typing import Any, Dict

dir_path = os.path.dirname(os.path.realpath(__file__))


def fake_GetJobRunModels(variables: Dict[str, Any]):
with open(f"{dir_path}/jaffle_shop.json") as f:
return f.read()
Loading

0 comments on commit 3f3b432

Please sign in to comment.