-
Notifications
You must be signed in to change notification settings - Fork 205
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
866b91b
commit 8c53e8b
Showing
8 changed files
with
813 additions
and
769 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,93 +1,93 @@ | ||
from django.contrib.auth.models import AnonymousUser | ||
from django.test import TestCase | ||
from django.test.client import RequestFactory | ||
from django.test.utils import override_settings | ||
|
||
from unfold.settings import CONFIG_DEFAULTS | ||
from unfold.sites import UnfoldAdminSite | ||
|
||
|
||
class ColorsTestCase(TestCase): | ||
@override_settings( | ||
UNFOLD={ | ||
**CONFIG_DEFAULTS, | ||
**{ | ||
"COLORS": { | ||
"primary": { | ||
50: "#f0f9ff", | ||
100: "#e0f2fe", | ||
200: "#bae6fd", | ||
300: "#7dd3fc", | ||
400: "#38bdf8", | ||
500: "#0ea5e9", | ||
600: "#0284c7", | ||
700: "#0369a1", | ||
800: "#075985", | ||
900: "#0c4a6e", | ||
950: "#082f49", | ||
} | ||
}, | ||
@override_settings( | ||
UNFOLD={ | ||
**CONFIG_DEFAULTS, | ||
**{ | ||
"COLORS": { | ||
"primary": { | ||
50: "#f0f9ff", | ||
100: "#e0f2fe", | ||
200: "#bae6fd", | ||
300: "#7dd3fc", | ||
400: "#38bdf8", | ||
500: "#0ea5e9", | ||
600: "#0284c7", | ||
700: "#0369a1", | ||
800: "#075985", | ||
900: "#0c4a6e", | ||
950: "#082f49", | ||
} | ||
}, | ||
} | ||
) | ||
def test_colors_hex_to_rgb(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertTrue("colors" in context) | ||
self.assertTrue("primary" in context["colors"]) | ||
}, | ||
} | ||
) | ||
def test_colors_hex_to_rgb(): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
|
||
self.assertEqual(context["colors"]["primary"][50], "240 249 255") | ||
self.assertEqual(context["colors"]["primary"][100], "224 242 254") | ||
self.assertEqual(context["colors"]["primary"][200], "186 230 253") | ||
self.assertEqual(context["colors"]["primary"][300], "125 211 252") | ||
self.assertEqual(context["colors"]["primary"][400], "56 189 248") | ||
self.assertEqual(context["colors"]["primary"][500], "14 165 233") | ||
self.assertEqual(context["colors"]["primary"][600], "2 132 199") | ||
self.assertEqual(context["colors"]["primary"][700], "3 105 161") | ||
self.assertEqual(context["colors"]["primary"][800], "7 89 133") | ||
self.assertEqual(context["colors"]["primary"][900], "12 74 110") | ||
self.assertEqual(context["colors"]["primary"][950], "8 47 73") | ||
assert "colors" in context | ||
assert "primary" in context["colors"] | ||
|
||
@override_settings( | ||
UNFOLD={ | ||
**CONFIG_DEFAULTS, | ||
**{ | ||
"COLORS": { | ||
"primary": { | ||
50: "240 249 255", | ||
100: "224 242 254", | ||
200: "186 230 253", | ||
300: "125 211 252", | ||
400: "56 189 248", | ||
500: "14 165 233", | ||
600: "2 132 199", | ||
700: "3 105 161", | ||
800: "7 89 133", | ||
900: "12 74 110", | ||
950: "8 47 73", | ||
} | ||
}, | ||
assert context["colors"]["primary"][50] == "240 249 255" | ||
assert context["colors"]["primary"][100] == "224 242 254" | ||
assert context["colors"]["primary"][200] == "186 230 253" | ||
assert context["colors"]["primary"][300] == "125 211 252" | ||
assert context["colors"]["primary"][400] == "56 189 248" | ||
assert context["colors"]["primary"][500] == "14 165 233" | ||
assert context["colors"]["primary"][600] == "2 132 199" | ||
assert context["colors"]["primary"][700] == "3 105 161" | ||
assert context["colors"]["primary"][800] == "7 89 133" | ||
assert context["colors"]["primary"][900] == "12 74 110" | ||
assert context["colors"]["primary"][950] == "8 47 73" | ||
|
||
|
||
@override_settings( | ||
UNFOLD={ | ||
**CONFIG_DEFAULTS, | ||
**{ | ||
"COLORS": { | ||
"primary": { | ||
50: "240 249 255", | ||
100: "224 242 254", | ||
200: "186 230 253", | ||
300: "125 211 252", | ||
400: "56 189 248", | ||
500: "14 165 233", | ||
600: "2 132 199", | ||
700: "3 105 161", | ||
800: "7 89 133", | ||
900: "12 74 110", | ||
950: "8 47 73", | ||
} | ||
}, | ||
} | ||
) | ||
def test_colors_rgb(self): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
self.assertTrue("colors" in context) | ||
self.assertTrue("primary" in context["colors"]) | ||
}, | ||
} | ||
) | ||
def test_colors_rgb(): | ||
admin_site = UnfoldAdminSite() | ||
request = RequestFactory().get("/rand") | ||
request.user = AnonymousUser() | ||
context = admin_site.each_context(request) | ||
assert "colors" in context | ||
assert "primary" in context["colors"] | ||
|
||
self.assertEqual(context["colors"]["primary"][50], "240 249 255") | ||
self.assertEqual(context["colors"]["primary"][100], "224 242 254") | ||
self.assertEqual(context["colors"]["primary"][200], "186 230 253") | ||
self.assertEqual(context["colors"]["primary"][300], "125 211 252") | ||
self.assertEqual(context["colors"]["primary"][400], "56 189 248") | ||
self.assertEqual(context["colors"]["primary"][500], "14 165 233") | ||
self.assertEqual(context["colors"]["primary"][600], "2 132 199") | ||
self.assertEqual(context["colors"]["primary"][700], "3 105 161") | ||
self.assertEqual(context["colors"]["primary"][800], "7 89 133") | ||
self.assertEqual(context["colors"]["primary"][900], "12 74 110") | ||
self.assertEqual(context["colors"]["primary"][950], "8 47 73") | ||
assert context["colors"]["primary"][50] == "240 249 255" | ||
assert context["colors"]["primary"][100] == "224 242 254" | ||
assert context["colors"]["primary"][200] == "186 230 253" | ||
assert context["colors"]["primary"][300] == "125 211 252" | ||
assert context["colors"]["primary"][400] == "56 189 248" | ||
assert context["colors"]["primary"][500] == "14 165 233" | ||
assert context["colors"]["primary"][600] == "2 132 199" | ||
assert context["colors"]["primary"][700] == "3 105 161" | ||
assert context["colors"]["primary"][800] == "7 89 133" | ||
assert context["colors"]["primary"][900] == "12 74 110" | ||
assert context["colors"]["primary"][950] == "8 47 73" |
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.