Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
[admin] Fixed possible import error case when adding new Config
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Feb 17, 2016
1 parent b62d82b commit c66f74f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion django_netjsonconfig/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def clean_templates(self):
config=self.data.get('config'))
else:
config = self.instance
if templates:
if config.backend and templates:
Config.clean_templates(action='pre_add',
instance=config,
sender=config.templates,
Expand Down
13 changes: 13 additions & 0 deletions django_netjsonconfig/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,16 @@ def test_uuid_field_in_change(self):
response = self.client.get(path)
self.assertEqual(response.status_code, 200)
self.assertContains(response, 'field-id')

def test_empty_backend_import_error(self):
t = Template.objects.first()
path = reverse('admin:django_netjsonconfig_config_add')
params = {
'name': 'empty-backend',
'key': self.TEST_KEY,
'templates': str(t.pk),
'backend': '',
'config': json.dumps({'general': {'hostname': 'config'}})
}
response = self.client.post(path, params)
self.assertIn('errors field-backend', str(response.content))

0 comments on commit c66f74f

Please sign in to comment.