Skip to content

Commit

Permalink
test: unicode collections and separate pytest fixtures (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
gouline authored Dec 20, 2024
1 parent a9eec40 commit c579c0c
Show file tree
Hide file tree
Showing 24 changed files with 163 additions and 140 deletions.
Binary file modified sandbox/metabase.db/metabase.db.mv.db
Binary file not shown.
19 changes: 19 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import pytest

from tests._mocks import TMP_PATH, MockDbtMetabase, MockMetabase


@pytest.fixture(name="core")
def fixture_core() -> MockDbtMetabase:
c = MockDbtMetabase()
c._ModelsMixin__SYNC_PERIOD = 1 # type: ignore
return c


@pytest.fixture(name="metabase")
def fixture_metabase() -> MockMetabase:
return MockMetabase(url="http://localhost")


def setup_module():
TMP_PATH.mkdir(exist_ok=True)
4 changes: 2 additions & 2 deletions tests/fixtures/api/card/27.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "Orders and customers",
"archived": false,
"view_count": 446,
"view_count": 458,
"collection_position": null,
"table_id": 10,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -561,7 +561,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/api/card/28.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 223,
"view_count": 229,
"collection_position": null,
"table_id": 10,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -549,7 +549,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/api/card/29.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 222,
"view_count": 228,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -41,7 +41,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/api/card/30.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "Dummy 1",
"archived": false,
"view_count": 43,
"view_count": 47,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -41,7 +41,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/api/card/31.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "Dummy 2",
"archived": false,
"view_count": 43,
"view_count": 47,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -41,7 +41,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/api/card/32.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": "CTE SQL",
"archived": false,
"view_count": 34,
"view_count": 38,
"collection_position": null,
"table_id": null,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -276,7 +276,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand Down
32 changes: 20 additions & 12 deletions tests/fixtures/api/card/33.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 15,
"view_count": 19,
"collection_position": null,
"table_id": 18,
"can_run_adhoc_query": true,
Expand Down Expand Up @@ -146,7 +146,7 @@
"creator": {
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_login": "2024-11-02T04:41:42.402168Z",
"last_login": "2024-12-20T12:30:47.814008Z",
"is_qbnewb": false,
"is_superuser": true,
"id": 1,
Expand All @@ -158,17 +158,17 @@
"can_write": true,
"database_id": 2,
"enable_embedding": false,
"collection_id": null,
"collection_id": 3,
"query_type": "query",
"name": "Transactions",
"last_query_start": "2024-10-12T03:53:32.250619Z",
"last_query_start": "2024-12-20T12:30:05.862314Z",
"dashboard_count": 0,
"last_used_at": "2024-10-12T03:43:09.869884Z",
"last_used_at": "2024-12-20T12:30:05.932096Z",
"type": "question",
"average_query_time": 114.5,
"average_query_time": 134.33333333333334,
"creator_id": 1,
"moderation_reviews": [],
"updated_at": "2024-10-12T01:52:30.606845Z",
"updated_at": "2024-12-20T12:30:11.735631Z",
"made_public_by_id": null,
"embedding_params": null,
"cache_ttl": null,
Expand All @@ -189,18 +189,26 @@
"email": "[email protected]",
"first_name": "dbtmetabase",
"last_name": null,
"timestamp": "2024-10-11T23:46:29.299411Z"
"timestamp": "2024-12-20T12:30:11.782155Z"
},
"visualization_settings": {
"table.cell_column": "payment_id"
},
"collection": {
"metabase.models.collection.root/is-root?": true,
"authority_level": null,
"name": "Our analytics",
"description": null,
"archived": false,
"slug": "%D0%BA%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D0%B8%D1%8F",
"name": "\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f",
"personal_owner_id": null,
"type": null,
"is_sample": false,
"id": 3,
"entity_id": "4Zdu-bk8RhwuFiEiRXuOH",
"location": "/",
"namespace": null,
"is_personal": false,
"id": "root",
"can_write": true
"created_at": "2024-12-20T12:29:39.063908Z"
},
"metabase_version": "v0.50.5 (48f6978)",
"parameters": [],
Expand Down
17 changes: 17 additions & 0 deletions tests/fixtures/api/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,22 @@
"namespace": null,
"is_personal": true,
"created_at": "2024-06-19T11:49:38.03895Z"
},
{
"authority_level": null,
"description": null,
"archived": false,
"slug": "%D0%BA%D0%BE%D0%BB%D0%BB%D0%B5%D0%BA%D1%86%D0%B8%D1%8F",
"can_write": true,
"name": "\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f",
"personal_owner_id": null,
"type": null,
"is_sample": false,
"id": 3,
"entity_id": "4Zdu-bk8RhwuFiEiRXuOH",
"location": "/",
"namespace": null,
"is_personal": false,
"created_at": "2024-12-20T12:29:39.063908Z"
}
]
25 changes: 25 additions & 0 deletions tests/fixtures/api/collection/3/items.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"description": null,
"collection_position": null,
"can_write": true,
"database_id": 2,
"collection_id": 3,
"name": "Transactions",
"fully_parameterized": true,
"moderated_status": null,
"id": 33,
"display": "table",
"entity_id": "ZRX529pNYbPiCLCi8HvZ6",
"collection_preview": true,
"last-edit-info": {
"id": 1,
"last_name": null,
"first_name": "dbtmetabase",
"email": "[email protected]",
"timestamp": "2024-12-20T12:30:11.782155Z"
},
"location": null,
"model": "card"
}
]
23 changes: 0 additions & 23 deletions tests/fixtures/api/collection/root/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,5 @@
},
"location": null,
"model": "dashboard"
},
{
"description": null,
"collection_position": null,
"can_write": true,
"database_id": 2,
"collection_id": null,
"name": "Transactions",
"fully_parameterized": true,
"moderated_status": null,
"id": 33,
"display": "table",
"entity_id": "ZRX529pNYbPiCLCi8HvZ6",
"collection_preview": true,
"last-edit-info": {
"id": 1,
"last_name": null,
"first_name": "dbtmetabase",
"email": "[email protected]",
"timestamp": "2024-10-11T23:46:29.299411Z"
},
"location": null,
"model": "card"
}
]
8 changes: 4 additions & 4 deletions tests/fixtures/api/dashboard/2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Dashboard is a dashboard is a dashboard",
"archived": false,
"view_count": 118,
"view_count": 121,
"collection_position": null,
"dashcards": [
{
Expand All @@ -14,7 +14,7 @@
"cache_invalidated_at": null,
"description": "Orders and customers",
"archived": false,
"view_count": 446,
"view_count": 458,
"collection_position": null,
"table_id": 10,
"result_metadata": [
Expand Down Expand Up @@ -653,7 +653,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 223,
"view_count": 229,
"collection_position": null,
"table_id": 10,
"result_metadata": [
Expand Down Expand Up @@ -1266,7 +1266,7 @@
"cache_invalidated_at": null,
"description": null,
"archived": false,
"view_count": 222,
"view_count": 228,
"collection_position": null,
"table_id": null,
"result_metadata": [
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/api/database.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"caveats": null,
"creator_id": 1,
"is_full_sync": true,
"updated_at": "2024-11-02T04:30:07.348325Z",
"updated_at": "2024-12-20T12:28:30.976262Z",
"native_permissions": "write",
"cache_ttl": null,
"details": {
Expand Down
Loading

0 comments on commit c579c0c

Please sign in to comment.