diff --git a/setup.py b/setup.py index 999490f5..01a55f2d 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ def read_file(filename): filepath = os.path.join(file_dir, filename) return open(filepath).read() + # Fix for dateutil/SSL py3 support if sys.version_info >= (3,): dateutil = 'python-dateutil >= 2' diff --git a/speeches/forms.py b/speeches/forms.py index 74e3fac3..8c19cdd0 100644 --- a/speeches/forms.py +++ b/speeches/forms.py @@ -615,6 +615,7 @@ def clean(self): _('Timestamps must be distinct')) previous_timestamp = timestamp + RecordingTimestampFormSet = inlineformset_factory( Recording, RecordingTimestamp, diff --git a/speeches/templatetags/pagination_tags.py b/speeches/templatetags/pagination_tags.py index e7687121..c082f3c5 100644 --- a/speeches/templatetags/pagination_tags.py +++ b/speeches/templatetags/pagination_tags.py @@ -135,5 +135,6 @@ def paginate(context, window=DEFAULT_WINDOW, hashtag=''): except (KeyError, AttributeError): return {} + register.inclusion_tag('pagination/pagination.html', takes_context=True)( paginate) diff --git a/speeches/tests/importer_tests.py b/speeches/tests/importer_tests.py index d2c8e9de..d88f290b 100644 --- a/speeches/tests/importer_tests.py +++ b/speeches/tests/importer_tests.py @@ -40,12 +40,12 @@ def setUp(self): self.importer = ImportAkomaNtoso(instance=self.instance, commit=True) def _list_sections(self): - # Make mapping {section name: list of its speeches' texts} + # Make list [section name: list of its speeches' texts} sections = {section.id: [] for section in Section.objects.all()} for speech in Speech.objects.all(): if speech.section_id: sections[speech.section_id].append(speech.text) - return {section.title: sections[section.id] for section in Section.objects.all()} + return [(section.title, sections[section.id]) for section in Section.objects.all()] def test_import_sample_file(self): self.importer.import_document( @@ -65,77 +65,77 @@ def test_already_imported(self): 'speeches/fixtures/test_inputs/test_xpath.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Hello

']} + [('This is the title', ['

Hello

'])] ) ImportAkomaNtoso(instance=self.instance, commit=True, clobber='skip').import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Hello

']} + [('This is the title', ['

Hello

'])] ) ImportAkomaNtoso(instance=self.instance, commit=True, clobber='merge').import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Hello

', '

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Hello

', '

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) ImportAkomaNtoso(instance=self.instance, commit=True, clobber='replace').import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) ImportAkomaNtoso(instance=self.instance, commit=True).import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - 'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) def test_not_already_imported(self): ImportAkomaNtoso(instance=self.instance, commit=True, clobber='skip').import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) Section.objects.all().delete() ImportAkomaNtoso(instance=self.instance, commit=True, clobber='merge').import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) Section.objects.all().delete() ImportAkomaNtoso(instance=self.instance, commit=True, clobber='replace').import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) Section.objects.all().delete() ImportAkomaNtoso(instance=self.instance, commit=True).import_document( 'speeches/tests/data/fake_http/test_clobber.xml') self.assertEqual( self._list_sections(), - {'This is the title': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('This is the title', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) Section.objects.all().delete() def test_empty_title(self): @@ -143,49 +143,49 @@ def test_empty_title(self): 'speeches/fixtures/test_inputs/test_empty_title.xml') self.assertEqual( self._list_sections(), - {'Untitled': ['

Hello

'], - 'Untitled': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('Untitled', ['

Hello

']), + ('Untitled', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) ImportAkomaNtoso(instance=self.instance, commit=True, clobber='skip').import_document( 'speeches/fixtures/test_inputs/test_empty_title.xml') self.assertEqual( self._list_sections(), - {'Untitled': ['

Hello

'], - 'Untitled': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('Untitled', ['

Hello

']), + ('Untitled', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) ImportAkomaNtoso(instance=self.instance, commit=True, clobber='merge').import_document( 'speeches/fixtures/test_inputs/test_empty_title.xml') self.assertEqual( self._list_sections(), - {'Untitled': ['

Hello

', '

Hello

', '

Howdy

'], - 'Untitled': ['

Howdy

'], - 'Conclusions': ['

Bye

', '

Bye

'], - }) + [('Untitled', ['

Hello

', '

Hello

', '

Howdy

']), + ('Untitled', ['

Howdy

']), + ('Conclusions', ['

Bye

', '

Bye

']), + ]) ImportAkomaNtoso(instance=self.instance, commit=True, clobber='replace').import_document( 'speeches/fixtures/test_inputs/test_empty_title.xml') self.assertEqual( self._list_sections(), - {'Untitled': ['

Hello

'], - 'Untitled': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('Untitled', ['

Hello

']), + ('Untitled', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) ImportAkomaNtoso(instance=self.instance, commit=True).import_document( 'speeches/fixtures/test_inputs/test_empty_title.xml') self.assertEqual( self._list_sections(), - {'Untitled': ['

Hello

'], - 'Untitled': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - 'Untitled': ['

Hello

'], - 'Untitled': ['

Howdy

'], - 'Conclusions': ['

Bye

'], - }) + [('Untitled', ['

Hello

']), + ('Untitled', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ('Untitled', ['

Hello

']), + ('Untitled', ['

Howdy

']), + ('Conclusions', ['

Bye

']), + ]) def test_empty_docDate(self): self.importer.import_document(