546 |
546 |
|
547 |
547 |
cell = LinkCell.objects.get()
|
548 |
548 |
assert cell.url == 'https://example.com'
|
|
549 |
|
|
550 |
|
|
551 |
def test_import_export_duplicated_slugs():
|
|
552 |
first_page = Page.objects.create(title='Title', slug='title', description='1')
|
|
553 |
output = get_output_of_command('export_site')
|
|
554 |
|
|
555 |
# create real situation where a subpage has the same slug as a top-level page
|
|
556 |
second_page = Page.objects.create(title='Test', slug='test')
|
|
557 |
third_page = Page.objects.create(title='Title', slug='title', description='test', parent=second_page)
|
|
558 |
first_page.description = '2'
|
|
559 |
first_page.save()
|
|
560 |
|
|
561 |
import_site(data=json.loads(output))
|
|
562 |
assert Page.objects.count() == 3
|
|
563 |
|
|
564 |
# top-level page has been updated
|
|
565 |
first_page.refresh_from_db()
|
|
566 |
assert first_page.description == '1'
|
|
567 |
|
|
568 |
# same slug subpage was left untouched
|
|
569 |
third_page.refresh_from_db()
|
|
570 |
assert third_page.description == 'test'
|
|
571 |
|
|
572 |
output = get_output_of_command('export_site')
|
|
573 |
third_page.description = ''
|
|
574 |
third_page.save()
|
|
575 |
|
|
576 |
import_site(data=json.loads(output))
|
|
577 |
assert Page.objects.count() == 3
|
|
578 |
|
|
579 |
# top level page was left untouched
|
|
580 |
first_page.refresh_from_db()
|
|
581 |
assert first_page.description == '1'
|
|
582 |
|
|
583 |
# same slug subpage has been updated
|
|
584 |
third_page.refresh_from_db()
|
|
585 |
assert third_page.description == 'test'
|
|
586 |
|
|
587 |
Page.objects.all().delete()
|
|
588 |
import_site(data=json.loads(output))
|
|
589 |
assert Page.objects.count() == 3
|
|
590 |
assert Page.objects.filter(parent__isnull=True).count() == 2
|
549 |
|
-
|