summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-12-20 15:47:34 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-12-21 15:07:32 (GMT)
commit71421c4266e69b1106ad7195183a13389369a9e3 (patch)
treee4f6572cbd07e6f1d97de19ca2425b0e070945e5
parent04244f5ad57250ff36084ccd0d7b29973e28a8a6 (diff)
downloadcombo-71421c4266e69b1106ad7195183a13389369a9e3.zip
combo-71421c4266e69b1106ad7195183a13389369a9e3.tar.gz
combo-71421c4266e69b1106ad7195183a13389369a9e3.tar.bz2
manager: fix handling of missing groups with python 3 (#38674)v2.49
-rw-r--r--combo/manager/views.py2
-rw-r--r--tests/test_manager.py22
2 files changed, 23 insertions, 1 deletions
diff --git a/combo/manager/views.py b/combo/manager/views.py
index c2f375c..5992fa2 100644
--- a/combo/manager/views.py
+++ b/combo/manager/views.py
@@ -83,7 +83,7 @@ class SiteImportView(FormView):
try:
import_site(json_site)
except MissingGroups as e:
- form.add_error('site_json', unicode(e))
+ form.add_error('site_json', force_text(e))
return self.form_invalid(form)
return super(SiteImportView, self).form_valid(form)
diff --git a/tests/test_manager.py b/tests/test_manager.py
index 5cdeac9..0b9b7ae 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -440,6 +440,28 @@ def test_site_export_import(app, admin_user):
resp = resp.form.submit()
assert 'File is not in the expected JSON format.' in resp.text
+def test_site_export_import_missing_group(app, admin_user):
+ Page.objects.all().delete()
+ group = Group.objects.create(name='foobar')
+ page1 = Page(title='One', slug='one', template_name='standard')
+ page1.save()
+ page1.groups.set([group])
+
+ app = login(app)
+ resp = app.get('/manage/')
+ resp = resp.click('Export Site')
+ assert resp.headers['content-type'] == 'application/json'
+ site_export = resp.body
+
+ Page.objects.all().delete()
+ group.delete()
+
+ app = login(app)
+ resp = app.get('/manage/')
+ resp = resp.click('Import Site')
+ resp.form['site_json'] = Upload('site-export.json', site_export, 'application/json')
+ resp = resp.form.submit()
+ assert 'Missing groups: foobar' in resp.text
def test_duplicate_page(app, admin_user):
page = Page.objects.create(title='One', slug='one', template_name='standard')