forked from markfinger/python-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_django_integration.py
More file actions
43 lines (37 loc) · 1.43 KB
/
test_django_integration.py
File metadata and controls
43 lines (37 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
import datetime
from django.test import TestCase
from django.utils import timezone
from optional_django.env import DJANGO_CONFIGURED
from react.render import render_component
from react import conf
from .settings import Components
class TestDjangoIntegration(TestCase):
__test__ = DJANGO_CONFIGURED
def test_can_serialize_datetime_values_in_props(self):
component = render_component(
Components.HELLO_WORLD_JSX,
{
'name': 'world!',
'datetime': datetime.datetime(2015, 1, 2, 3, 4, 5, tzinfo=timezone.utc),
'date': datetime.date(2015, 1, 2),
'time': datetime.time(3, 4, 5),
},
)
deserialized = json.loads(component.props)
self.assertEqual(
deserialized,
{
'name': 'world!',
'datetime': '2015-01-02T03:04:05Z',
'date': '2015-01-02',
'time': '03:04:05',
}
)
def test_relative_paths_are_resolved_via_the_static_file_finder(self):
component = render_component(Components.DJANGO_REL_PATH, to_static_markup=True)
self.assertEqual(str(component), '<span>You found me.</span>')
def test_django_settings_are_proxied(self):
self.assertEqual(conf.settings.RENDER, True)
with self.settings(REACT={'RENDER': False}):
self.assertEqual(conf.settings.RENDER, False)