-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename settings.py to conf.py and add additional test cases
- Loading branch information
Showing
8 changed files
with
59 additions
and
16 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
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,44 @@ | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.test import TestCase, override_settings | ||
|
||
from modeltrans.conf import check_fallback_chain | ||
|
||
|
||
class FallbackConfTest(TestCase): | ||
|
||
@override_settings( | ||
MODELTRANS_FALLBACK={ | ||
'fy': ('nl', 'en') | ||
} | ||
) | ||
def test_fallback_must_have_default(self): | ||
message = 'MODELTRANS_FALLBACK setting must have a `default` key.' | ||
|
||
with self.assertRaisesMessage(ImproperlyConfigured, message): | ||
check_fallback_chain() | ||
|
||
@override_settings( | ||
MODELTRANS_AVAILABLE_LANGUAGES=('nl', 'en'), | ||
MODELTRANS_FALLBACK={ | ||
'default': ('en', ), | ||
'fy': ('nl', 'en') | ||
} | ||
) | ||
def test_fallback_must_use_available_languages_as_key(self): | ||
message = 'MODELTRANS_FALLBACK contains language `fy` which is not in MODELTRANS_AVAILABLE_LANGUAGES' | ||
|
||
with self.assertRaisesMessage(ImproperlyConfigured, message): | ||
check_fallback_chain() | ||
|
||
@override_settings( | ||
MODELTRANS_AVAILABLE_LANGUAGES=('fy', 'nl', 'en'), | ||
MODELTRANS_FALLBACK={ | ||
'default': ('en', ), | ||
'fy': ('nl', 'fr', 'en') | ||
} | ||
) | ||
def test_fallback_must_use_available_languages_in_chain(self): | ||
message = 'MODELTRANS_FALLBACK contains language `fr` which is not in MODELTRANS_AVAILABLE_LANGUAGES' | ||
|
||
with self.assertRaisesMessage(ImproperlyConfigured, message): | ||
check_fallback_chain() |