-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d14ff56
commit 05221ff
Showing
23 changed files
with
837 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,42 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from alembic_postgresql_enum.get_enum_data import TableReference, get_declared_enums | ||
from tests.schemas import get_schema_with_enum_variants, DEFAULT_SCHEMA, USER_STATUS_ENUM_NAME, USER_TABLE_NAME, \ | ||
USER_STATUS_COLUMN_NAME, get_schema_by_declared_enum_values, get_declared_enum_values_with_orders_and_users | ||
from tests.schemas import ( | ||
get_schema_with_enum_variants, | ||
DEFAULT_SCHEMA, | ||
USER_STATUS_ENUM_NAME, | ||
USER_TABLE_NAME, | ||
USER_STATUS_COLUMN_NAME, | ||
get_schema_by_declared_enum_values, | ||
get_declared_enum_values_with_orders_and_users, | ||
) | ||
|
||
if TYPE_CHECKING: | ||
from sqlalchemy import Connection | ||
|
||
|
||
def test_with_user_schema(connection: 'Connection'): | ||
def test_with_user_schema(connection: "Connection"): | ||
enum_variants = ["active", "passive"] | ||
declared_schema = get_schema_with_enum_variants(enum_variants) | ||
|
||
function_result = get_declared_enums(declared_schema, DEFAULT_SCHEMA, DEFAULT_SCHEMA, connection) | ||
function_result = get_declared_enums( | ||
declared_schema, DEFAULT_SCHEMA, DEFAULT_SCHEMA, connection | ||
) | ||
|
||
assert function_result.enum_values == { | ||
USER_STATUS_ENUM_NAME: tuple(enum_variants) | ||
} | ||
assert function_result.enum_values == {USER_STATUS_ENUM_NAME: tuple(enum_variants)} | ||
assert function_result.enum_table_references == { | ||
USER_STATUS_ENUM_NAME: frozenset((TableReference(USER_TABLE_NAME, USER_STATUS_COLUMN_NAME),)) | ||
USER_STATUS_ENUM_NAME: frozenset( | ||
(TableReference(USER_TABLE_NAME, USER_STATUS_COLUMN_NAME),) | ||
) | ||
} | ||
|
||
|
||
def test_with_multiple_enums(connection: 'Connection'): | ||
def test_with_multiple_enums(connection: "Connection"): | ||
declared_enum_values = get_declared_enum_values_with_orders_and_users() | ||
declared_schema = get_schema_by_declared_enum_values(declared_enum_values) | ||
|
||
function_result = get_declared_enums(declared_schema, DEFAULT_SCHEMA, DEFAULT_SCHEMA, connection) | ||
function_result = get_declared_enums( | ||
declared_schema, DEFAULT_SCHEMA, DEFAULT_SCHEMA, connection | ||
) | ||
|
||
assert function_result == declared_enum_values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.