-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve dbname styling / add tests for non-identifier names / improve…
… docs (#251) Changes: - add "" around db names so names with spaces at end or start can be identified despite they are bad names - test that broken migrations fail - merge double section in migrations.md - Document templates better
- Loading branch information
Showing
8 changed files
with
140 additions
and
33 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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
import edgy | ||
from edgy import Instance | ||
from edgy.contrib.permissions import BasePermission | ||
from tests.settings import TEST_ALTERNATIVE_DATABASE, TEST_DATABASE | ||
|
||
pytestmark = pytest.mark.anyio | ||
models = edgy.Registry( | ||
database=TEST_DATABASE, | ||
extra={"ano ther ": TEST_ALTERNATIVE_DATABASE}, | ||
with_content_type=True, | ||
) | ||
basedir = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
class User(edgy.StrictModel): | ||
name = edgy.fields.CharField(max_length=100) | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
class Group(edgy.StrictModel): | ||
name = edgy.fields.CharField(max_length=100) | ||
users = edgy.fields.ManyToMany("User", embed_through=False) | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
class Permission(BasePermission): | ||
users = edgy.fields.ManyToMany("User", embed_through=False) | ||
groups = edgy.fields.ManyToMany("Group", embed_through=False) | ||
name_model: str = edgy.fields.CharField(max_length=100, null=True) | ||
obj = edgy.fields.ForeignKey("ContentType", null=True) | ||
|
||
class Meta: | ||
registry = models | ||
unique_together = [("name", "name_model", "obj")] | ||
|
||
|
||
class Signal(edgy.StrictModel): | ||
user = edgy.fields.ForeignKey(User, no_constraint=True) | ||
signal_type = edgy.fields.CharField(max_length=100) | ||
database = models.extra["ano ther "] | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
class Unrelated(edgy.StrictModel): | ||
name = edgy.fields.CharField(max_length=100) | ||
database = models.extra["ano ther "] | ||
content_type = edgy.fields.ExcludeField() | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
edgy.monkay.set_instance(Instance(registry=models)) |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from typing import Union | ||
|
||
from edgy.conf.global_settings import EdgySettings | ||
|
||
|
||
class TestSettings(EdgySettings): | ||
migrate_databases: list[Union[str, None]] = [None, "ano ther "] |