Commit 0e48d8cc authored by Luca Cristaldi's avatar Luca Cristaldi

simplify unitest

parent a3d7255c
......@@ -66,7 +66,14 @@ Get a revenue journal::
... ('code', '=', 'REV'),
... ])
Create membership::
Create memberships::
>>> def periodgen(startDate,deltaTime,quantity):
... firstDate = startDate
... for period in range(quantity):
... lastDate = firstDate + deltaTime
... yield (firstDate,lastDate)
... firstDate = lastDate + datetime.timedelta(days=1)
>>> start_date = datetime.date(2018,1,1)
>>> fiscalMonth = 13
......@@ -78,8 +85,14 @@ Create membership::
>>> membership1.name = "membership1"
>>> membership1.account_revenue = revenue
>>> membership1.journal = journal_revenue
>>> datedeltas = [(start_date + timedelta*(n-1) + datetime.timedelta(days=1),start_date + timedelta*n,f"{membership1.name} - {n}") for n in range(1,fiscalMonth+1)]
>>> periods1 = [ membership1.periods.new(start_date=period[0],end_date=period[1], name=period[2], amount=Decimal(42)) for period in datedeltas ]
>>> periods1 = []
>>> for period in periodgen(start_date,timedelta,fiscalMonth):
... newPeriod = membership1.periods.new(
... start_date=period[0],
... end_date=period[1],
... name="test",
... amount=Decimal(42))
... periods1.append(newPeriod)
>>> membership1.save()
>>> start_date = datetime.date(2018,1,1)
......@@ -88,14 +101,28 @@ Create membership::
>>> membership2.name = "membership2:Electric boogaloo"
>>> membership2.account_revenue = revenue
>>> membership2.journal = journal_revenue
>>> datedeltas = [(start_date + timedelta*(n-1) + datetime.timedelta(days=1),start_date + timedelta*n,f"{membership2.name} - {n}") for n in range(1,fiscalMonth+1)]
>>> periods2 = [ membership2.periods.new(start_date=period[0],end_date=period[1], name=period[2], amount=Decimal(42)) for period in datedeltas ]
>>> periods2 = []
>>> for period in periodgen(start_date,timedelta,fiscalMonth):
... newPeriod = membership2.periods.new(
... start_date=period[0],
... end_date=period[1],
... name="test",
... amount=Decimal(42))
... periods2.append(newPeriod)
>>> membership2.save()
Add membership to member::
>>> memperships = [ membership1, membership2 ]
>>> _ = [ member.memberships.new(membership_type=m,start_date = start_date + datetime.timedelta(weeks=4),end_date = start_date + datetime.timedelta(weeks=50)) for m in memperships]
>>> _ = member.memberships.new(
... membership_type=membership1,
... start_date = start_date + datetime.timedelta(weeks=4),
... end_date = start_date + datetime.timedelta(weeks=50),
... )
>>> _ = member.memberships.new(
... membership_type=membership2,
... start_date = start_date + datetime.timedelta(weeks=4),
... end_date = start_date + datetime.timedelta(weeks=50),
... )
>>> member.join_date = start_date + datetime.timedelta(weeks=6)
>>> member.leave_date = start_date + datetime.timedelta(weeks=35)
>>> member.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment