Skip to content

Commit

Permalink
Placate flake8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncan Parkes committed Jan 14, 2015
1 parent a894760 commit 6ccba9a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 41 deletions.
1 change: 0 additions & 1 deletion speeches/forms.py
Expand Up @@ -655,4 +655,3 @@ def __init__(self, instance=None, *args, **kwargs):
),
widget=forms.RadioSelect(),
)

2 changes: 1 addition & 1 deletion speeches/importers/import_akomantoso.py
Expand Up @@ -13,7 +13,7 @@
logger = logging.getLogger(__name__)


class ImportAkomaNtoso (ImporterBase):
class ImportAkomaNtoso(ImporterBase):
start_date = None

def import_document(self, document_path):
Expand Down
2 changes: 1 addition & 1 deletion speeches/management/import_commands.py
Expand Up @@ -35,7 +35,7 @@ class ImportCommand(BaseCommand):
make_option(
'--merge-existing', action='store_const', const='merge', dest='clobber',
help='Whether to merge sections with the same heading'),
)
)

def handle(self, *args, **options):
verbosity = int(options['verbosity'])
Expand Down
59 changes: 24 additions & 35 deletions speeches/tests/importer_tests.py
Expand Up @@ -80,16 +80,16 @@ def test_already_imported(self):
self.assertEqual(
self._list_sections(),
{'This is the title': ['<p>Hello</p>', '<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

ImportAkomaNtoso(instance=self.instance, commit=True, clobber='replace').import_document(
'speeches/fixtures/test_inputs/test_clobber.xml')
self.assertEqual(
self._list_sections(),
{'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

ImportAkomaNtoso(instance=self.instance, commit=True).import_document(
'speeches/fixtures/test_inputs/test_clobber.xml')
Expand All @@ -98,44 +98,44 @@ def test_already_imported(self):
{'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>'],
'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

def test_not_already_imported(self):
ImportAkomaNtoso(instance=self.instance, commit=True, clobber='skip').import_document(
'speeches/fixtures/test_inputs/test_clobber.xml')
self.assertEqual(
self._list_sections(),
{'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})
Section.objects.all().delete()

ImportAkomaNtoso(instance=self.instance, commit=True, clobber='merge').import_document(
'speeches/fixtures/test_inputs/test_clobber.xml')
self.assertEqual(
self._list_sections(),
{'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})
Section.objects.all().delete()

ImportAkomaNtoso(instance=self.instance, commit=True, clobber='replace').import_document(
'speeches/fixtures/test_inputs/test_clobber.xml')
self.assertEqual(
self._list_sections(),
{'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})
Section.objects.all().delete()

ImportAkomaNtoso(instance=self.instance, commit=True).import_document(
'speeches/fixtures/test_inputs/test_clobber.xml')
self.assertEqual(
self._list_sections(),
{'This is the title': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})
Section.objects.all().delete()

def test_empty_title(self):
Expand All @@ -145,35 +145,35 @@ def test_empty_title(self):
self._list_sections(),
{'Untitled': ['<p>Hello</p>'],
'Untitled': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

ImportAkomaNtoso(instance=self.instance, commit=True, clobber='skip').import_document(
'speeches/fixtures/test_inputs/test_empty_title.xml')
self.assertEqual(
self._list_sections(),
{'Untitled': ['<p>Hello</p>'],
'Untitled': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

ImportAkomaNtoso(instance=self.instance, commit=True, clobber='merge').import_document(
'speeches/fixtures/test_inputs/test_empty_title.xml')
self.assertEqual(
self._list_sections(),
{'Untitled': ['<p>Hello</p>', '<p>Hello</p>', '<p>Howdy</p>'],
'Untitled': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>', '<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>', '<p>Bye</p>'],
})

ImportAkomaNtoso(instance=self.instance, commit=True, clobber='replace').import_document(
'speeches/fixtures/test_inputs/test_empty_title.xml')
self.assertEqual(
self._list_sections(),
{'Untitled': ['<p>Hello</p>'],
'Untitled': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

ImportAkomaNtoso(instance=self.instance, commit=True).import_document(
'speeches/fixtures/test_inputs/test_empty_title.xml')
Expand All @@ -184,8 +184,8 @@ def test_empty_title(self):
'Conclusions': ['<p>Bye</p>'],
'Untitled': ['<p>Hello</p>'],
'Untitled': ['<p>Howdy</p>'],
'Conclusions': ['<p>Bye</p>']
})
'Conclusions': ['<p>Bye</p>'],
})

def test_xpath_preface_elements(self):
self.importer.import_document(
Expand Down Expand Up @@ -308,17 +308,6 @@ def test_popolo_import_remote_single_json_file(self):
3,
)

def test_popolo_import_remote_single_json_file(self):
popolo_importer = PopoloImporter(
'http://example.com/welsh_assembly.json'
)
popolo_importer.import_all()

self.assertEqual(
Speaker.objects.filter(instance=popolo_importer.instance).count(),
3,
)


class PopoloImportFromLocalSourceTestCase(InstanceTestCase):
def test_import_persons(self):
Expand Down
8 changes: 5 additions & 3 deletions speeches/views.py
Expand Up @@ -707,7 +707,7 @@ def form_valid(self, form):
)

stats = importer.import_document(form.cleaned_data['location'])
except Exception as e:
except:
form._errors[NON_FIELD_ERRORS] = form.error_class(
[_('Sorry - something went wrong with the import')])
return self.form_invalid(form)
Expand All @@ -721,7 +721,8 @@ def form_valid(self, form):
messages.add_message(
self.request,
messages.SUCCESS,
_('Created: ') + ', '.join((
_('Created: ') + ', '.join(
(
ungettext(
"%(speakers)d speaker",
"%(speakers)d speakers",
Expand All @@ -737,7 +738,8 @@ def form_valid(self, form):
"%(speeches)d speeches",
speeches,
) % {'speeches': speeches},
))
)
)
)
else:
messages.add_message(
Expand Down

0 comments on commit 6ccba9a

Please sign in to comment.