33 |
33 |
Page.objects.create(title='One', slug='one')
|
34 |
34 |
Page.objects.create(title='Two', slug='two')
|
35 |
35 |
page = Page.objects.create(title='Three', slug='three')
|
|
36 |
Page.objects.create(title='Štiri', slug='four')
|
36 |
37 |
cell = TextCell(page=page, order=0, text='hello world', placeholder='content')
|
37 |
38 |
cell.save()
|
38 |
39 |
|
... | ... | |
59 |
60 |
|
60 |
61 |
def test_import_export(app, some_data):
|
61 |
62 |
output = get_output_of_command('export_site')
|
62 |
|
assert len(json.loads(output)['pages']) == 3
|
|
63 |
# test no ascii escape
|
|
64 |
assert not '\\u' in output
|
|
65 |
assert len(json.loads(output)['pages']) == 4
|
63 |
66 |
import_site(data={}, clean=True)
|
64 |
67 |
assert Page.objects.all().count() == 0
|
65 |
68 |
assert TextCell.objects.all().count() == 0
|
... | ... | |
81 |
84 |
f.flush()
|
82 |
85 |
call_command('import_site', f.name)
|
83 |
86 |
|
84 |
|
assert Page.objects.count() == 3
|
|
87 |
assert Page.objects.count() == 4
|
85 |
88 |
assert TextCell.objects.all().count() == 1
|
86 |
89 |
|
87 |
90 |
import_site(data={}, if_empty=True)
|
88 |
|
assert Page.objects.count() == 3
|
|
91 |
assert Page.objects.count() == 4
|
89 |
92 |
assert TextCell.objects.all().count() == 1
|
90 |
93 |
|
91 |
94 |
import_site(data=[], clean=True)
|
... | ... | |
103 |
106 |
Page.objects.all().delete()
|
104 |
107 |
import_site(data=payload)
|
105 |
108 |
|
106 |
|
assert Page.objects.count() == 3
|
|
109 |
assert Page.objects.count() == 4
|
107 |
110 |
two = Page.objects.get(slug='two')
|
108 |
111 |
assert two.parent.slug == 'one'
|
109 |
112 |
|
... | ... | |
117 |
120 |
Page.objects.all().delete()
|
118 |
121 |
import_site(data=payload)
|
119 |
122 |
|
120 |
|
assert Page.objects.count() == 3
|
|
123 |
assert Page.objects.count() == 4
|
121 |
124 |
for page in Page.objects.all():
|
122 |
125 |
assert page.parent is None
|
123 |
126 |
one = Page.objects.get(slug='one')
|
... | ... | |
128 |
131 |
old_export = Page.export_all_for_json()
|
129 |
132 |
Page.objects.all().delete()
|
130 |
133 |
import_site(data=old_export)
|
131 |
|
assert Page.objects.count() == 3
|
|
134 |
assert Page.objects.count() == 4
|
132 |
135 |
|
133 |
136 |
|
134 |
137 |
def test_import_export_map_layers(app, some_map_layers):
|
... | ... | |
202 |
205 |
cell.save()
|
203 |
206 |
|
204 |
207 |
output = get_output_of_command('export_site')
|
205 |
|
assert len(json.loads(output)['pages']) == 3
|
|
208 |
assert len(json.loads(output)['pages']) == 4
|
206 |
209 |
import_site(data={}, clean=True)
|
207 |
210 |
assert Page.objects.all().count() == 0
|
208 |
211 |
assert TextCell.objects.all().count() == 0
|
... | ... | |
225 |
228 |
group.save()
|
226 |
229 |
|
227 |
230 |
import_site(json.loads(output), clean=True)
|
228 |
|
assert Page.objects.all().count() == 3
|
|
231 |
assert Page.objects.all().count() == 4
|
229 |
232 |
assert TextCell.objects.all().count() == 1
|
230 |
233 |
|
231 |
234 |
page = Page.objects.get(slug='one')
|
... | ... | |
367 |
370 |
page['cells'][0]['fields']['extra_field_not_in_model'] = True
|
368 |
371 |
|
369 |
372 |
import_site(site_export)
|
370 |
|
assert Page.objects.count() == 3
|
|
373 |
assert Page.objects.count() == 4
|
371 |
374 |
assert TextCell.objects.count() == 1
|
372 |
375 |
|
373 |
376 |
|
374 |
|
-
|