def test__mail__MailAssignmentPreview_1(browser): """It can send Fehlende Arbeitsstunden.""" from sw.allotmentclub import Message, User, Member, Assignment from sw.allotmentclub import AssignmentAttendee from sw.allotmentclub.conftest import import_members import_members() assignment = Assignment.find_or_create( day=datetime.now(), accounting_year=datetime.now().year ) AssignmentAttendee.find_or_create( assignment=assignment, member=Member.query().filter(Member.lastname == 'Wehrmann').one(), hours=5) # No letter AssignmentAttendee.find_or_create( assignment=assignment, member=Member.query().filter(Member.lastname == 'Hennig').one(), hours=3) # Needs to pay less verein = Member.find_or_create(lastname="Verein") Message.create(id=245, members=[verein], user=User.create(), accounting_year=2018, subject="Fehlende Arbeitsstunden", body=MISSING_ASSIGMENT_BODY) transaction.commit() browser.login() with mock.patch('sw.allotmentclub.browser.letter.datetime') as dt: dt.now.return_value = datetime(2016, 3, 25) browser.open('http://localhost/mail/245/preview') assertFileEqual(browser.contents, 'test_mail_fehlarbeitsstunden_1.pdf')
def import_members(): parser = gocept.logging.ArgumentParser( description="Import members from excel file.") parser.add_argument('-c', '--config', default='portal.ini', help='Specify the config file. (default: portal.ini)') parser.add_argument('-i', '--input', default='members.xslx', help='Specify the input file. (default: members.xslx)') options = parser.parse_args() app = Application.from_filename(options.config) registry = pyramid.registry.Registry( bases=(zope.component.getGlobalSiteManager(), )) config = pyramid.config.Configurator(settings=app.settings, registry=registry) config.setup_registry(settings=app.settings) request = pyramid.testing.DummyRequest(_registry=registry) request.client_addr = '127.0.0.1' context = pyramid.threadlocal.manager.get().copy() context['request'] = request context['registry'] = registry pyramid.threadlocal.manager.push(context) with open(options.input, 'r') as file: reader = csv.reader(file, delimiter=';') for id, line in enumerate(reader): if id == 0: continue Member.find_or_create(title='', appellation='Herr', organization_id=2, lastname=line[0], firstname=line[1], street=line[2], zip=line[3], city=line[4], country='Deutschland', phone=line[5], mobile=line[6], email=line[7], birthday=line[8]) transaction.commit()
def test__mail__MailElectricityPreview_1(browser): """It can send Energieabrechnungen.""" from sw.allotmentclub import Message, User, Member from sw.allotmentclub.conftest import import_energy_meters, import_members import_members() import_energy_meters() verein = Member.find_or_create(lastname="Verein") Message.create(id=245, members=[verein], user=User.create(), accounting_year=2014, subject="Energieabrechnung", body=ENERGIEABRECHNUNG_BODY) transaction.commit() browser.login() with mock.patch('sw.allotmentclub.browser.letter.datetime') as dt: dt.now.return_value = datetime(2016, 3, 25) browser.open('http://localhost/mail/245/preview') assertFileEqual(browser.contents, 'test_mail_energieabrechnung_1.pdf')
def test_BankingAccountListReportView_1(browser): from sw.allotmentclub import Booking, BookingKind, Member from ...conftest import assertFileEqual import transaction kind = BookingKind.find_or_create( title='Energieabschlag I', shorttitle='ENA1') BookingKind.find_or_create( title='Energieabschlag II', shorttitle='ENA2') member = Member.find_or_create(lastname='Wehrmann', firstname='Sebastian') setUp() for b in Booking.query(): b.kind = kind b.member = member transaction.commit() browser.login() browser.open('http://localhost/accounts/report.pdf?for_year=2015') assertFileEqual(browser.contents, 'test_account_report_1.pdf')
def import_members(max=99999): from sw.allotmentclub import Member, Allotment, Parcel for line in [ [ '60', '102', '', 'Frau', 'Ines', 'Groß', 'Mittelweg 7', '01458', 'Ottendorf-Okrilla', '', '', '' ], [ '62', '104', '', 'Herr', 'Reiner', 'Pfeil', 'Schillerstr. 42', '06247', 'Bad Lauchstädt', '', '034635 32731', '' ], [ '64', '106', '', 'Frau', 'Astrid', 'Ritter', 'Brandenburgische Str. 27', '15366', 'Hönow', '', '', '' ], [ '67', '108', '', 'Herr', 'Sebastian', 'Wehrmann', 'Geseniusstr. 34', '06110', 'Halle', '', '', '0172 1096832' ], [ '70', '110', '', 'Herr', 'Johannes', 'Hennig', 'A.-Einstein-' 'Str. 15', '06237', 'Leuna', '', '03461 502682', '' ], [ '74', '112', '', 'Frau', 'Regina', 'Esser', 'Ringstr. 42', '06886', 'Wittenberg', '', '03491 662813', '' ], [ '76', '114', 'Dr.', 'Frau', 'Brigitte', 'Helbig', 'Wolfgang-' 'Heinze-Str. 20', '04277', 'Leipzig', '', '0341 3520609', '' ], [ '83', '118', '', 'Frau', 'Margit ', 'Götze', 'Heinrich-Heine' '-Str. 19', '06237', 'Leuna', '', '03461 811244', '' ], [ '92/93', '122/ 225', '', 'Herr', 'Claus', 'Masthoff', 'Paul-' 'Thiersch-Str. 16', '06124', 'Halle', '', '0345 6876407', '' ], [ '94/50', '124', '', 'Frau', 'Britta', 'Grimmling', 'Fors 190', '87391', 'Bollstabruk', 'Schweden', '', '0157 84943178' ], [ '150', '249/251', '', 'Herr', 'Lutz', 'Rösler', 'Cloppenburger Str. 12', '06126', 'Halle', '', '', '' ], [ '100/137', '405/406', '', 'Frau', 'Marlies', 'Leutloff', 'Wei' 'ßenfelser Str. 11c', '06231', 'Bad Dürrenberg', '', '', '' ], [ '', '', '', 'Herr', 'Günter', 'Tillack', 'Harry-S.-Truman-' 'Allee 4', '14167', 'Berlin', '', '', '0162 9541236' ], [ '153', '328', '', '', '', 'Leuna Bungalowgemeinschaft Roter ' 'See e.V.', 'Postfach 1106', '06773', 'Gräfenhainichen', '', '', '' ], ['58', '203', '', '', '', 'Werkstatt', '', '', '', '', '', ''] ]: if '/' in line[0] or '/' in line[1]: lines = [line[:], line[:]] else: lines = [line] if '/' in line[0]: p1, p2 = line[0].split('/') lines[0][0] = p1.strip() lines[1][0] = p2.strip() if '/' in line[1]: p1, p2 = line[1].split('/') lines[0][1] = p1.strip() lines[1][1] = p2.strip() for line in lines: member = Member.find_or_create(firstname=line[4], lastname=line[5]) member.title = line[2] member.appellation = line[3] member.street = line[6] member.zip = line[7] member.city = line[8] member.country = line[9] or 'Deutschland' member.phone = line[10] member.mobile = line[11] if line[1].strip(): allotment = Allotment.find_or_create(number=int(line[1]), member=member) if line[0].strip(): Parcel.find_or_create(number=int(line[0]), allotment=allotment) transaction.savepoint()