def test_protocol_json(self): with freeze(datetime(2018, 5, 4)): data = ProtocolData(self.meeting).get_processed_data() expected_data = copy.deepcopy(SAMPLE_MEETING_DATA) expected_data.update({'document': {'generated': '04.05.2018'}}) expected_data['meeting']['date'] = '13.12.2011' self.assertDictEqual(expected_data, data)
def get_sablon_for_paragraph(self, agenda_item): template = self._get_paragraph_template() if template is None: return return Sablon(self._get_paragraph_template()).process( ProtocolData(self.meeting, [agenda_item]).as_json())
def test_date_formatting_string_affects_protocol_json(self): api.portal.set_registry_record("sablon_date_format_string", u'%Y %m %d', interface=IMeetingSettings) with freeze(datetime(2018, 5, 4)): data = ProtocolData(self.meeting).get_processed_data() expected_data = copy.deepcopy(SAMPLE_MEETING_DATA) expected_data.update({'document': {'generated': '2018 05 04'}}) expected_data['meeting']['date'] = '2011 12 13' self.assertDictEqual(expected_data, data)
def add_sablon_for_paragraph(self, index, agenda_item, generator): committee = self.meeting.committee.resolve_committee() template = committee.get_paragraph_template() sablon = Sablon(template).process( ProtocolData(self.meeting, [agenda_item]).as_json()) filename = u'{:03d}_paragraph_{}.docx'.format( index, safe_unicode(agenda_item.title)) generator.add_file(filename, StringIO(sablon.file_data))
def test_add_members_handles_participants_are_no_longer_committee_memberships(self): create_session().delete(self.membership_peter) self.assertEquals( {'members': [{'fullname': u'B\xe4nni Anna', 'email': '*****@*****.**', 'role': None}, {'fullname': u'M\xfcller Franz', 'role': None, 'email': u'*****@*****.**'}, {'fullname': u'M\xfcller Peter', 'role': None, 'email': None}, ]}, ProtocolData(self.meeting).add_members())
def test_get_attending_members_handles_participants_are_no_longer_committee_memberships(self): create_session().delete(self.membership_anna) self.assertEquals( [{'firstname': 'Anna', 'lastname': u'B\xe4nni', 'fullname': u'B\xe4nni Anna', 'email': '*****@*****.**', 'role': None}, {'email': u'*****@*****.**', 'firstname': u'Franz', 'fullname': u'M\xfcller Franz', 'lastname': u'M\xfcller', 'role': None}, ], ProtocolData(self.meeting).get_attending_members())
def test_add_members_handles_participants_are_no_longer_committee_memberships( self): create_session().delete(self.membership_anna) self.assertEquals( { 'members': [ { 'firstname': 'Anna', 'lastname': u'B\xe4nni', 'fullname': u'B\xe4nni Anna', 'email': '*****@*****.**', 'role': None }, ] }, ProtocolData(self.meeting).add_members())
def test_protocol_json(self): data = ProtocolData(self.meeting).data self.assertDictEqual(SAMPLE_MEETING_DATA, data)
def get_agenda_item_suffix_sablon(self, agenda_item): template = self.meeting.get_agenda_item_suffix_template() if template is None: return return Sablon(template).process( ProtocolData(self.meeting, [agenda_item]).as_json())
def get_meeting_data(self, meeting): return ProtocolData(meeting)
def _export_paragraph_as_document(self, agenda_item, target_path): sablon = Sablon(self._get_paragraph_template()) sablon.process(ProtocolData(self.meeting, [agenda_item]).as_json()) with open(target_path, 'wb') as fio: fio.write(sablon.file_data)