Skip to content

Commit

Permalink
issue #178 - update make_screenshots.py for DB model changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jantman committed Mar 25, 2018
1 parent 008b70c commit 8ccac42
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions docs/make_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
import os
import re
from collections import defaultdict

index_head = """Screenshots
===========
"""

import os
import glob
import socket
Expand Down Expand Up @@ -73,6 +67,11 @@
from selenium.webdriver.chrome.options import Options
from PIL import Image

index_head = """Screenshots
===========
"""

format = "%(asctime)s [%(levelname)s %(filename)s:%(lineno)s - " \
"%(name)s.%(funcName)s() ] %(message)s"
logging.basicConfig(level=logging.DEBUG, format=format)
Expand Down Expand Up @@ -350,18 +349,26 @@ def _fuel_log_preshot(self):
assert veh is not None
for i in range(3, 33):
last_odo += 200 + randrange(-50, 50)
cpg = 2.0 + (randrange(-100, 100) / 100)
gals = 10.0 + (randrange(-300, 300) / 100)
cpg = Decimal('2.0') + Decimal(randrange(-100, 100) / 100)
gals = Decimal('10.0') + Decimal(randrange(-300, 300) / 100)
fill = FuelFill(
date=(dtnow() + timedelta(days=i)).date(),
cost_per_gallon=cpg,
cost_per_gallon=Decimal(
cpg.quantize(Decimal('.001'), rounding=ROUND_HALF_UP)
),
fill_location='foo',
gallons=gals,
gallons=Decimal(
gals.quantize(Decimal('.001'), rounding=ROUND_HALF_UP)
),
level_before=choice([0, 10, 20, 30, 40]),
level_after=100,
odometer_miles=last_odo,
reported_miles=last_odo,
total_cost=cpg * gals,
total_cost=Decimal(
(cpg * gals).quantize(
Decimal('.001'), rounding=ROUND_HALF_UP
)
),
vehicle=veh
)
data_sess.add(fill)
Expand Down Expand Up @@ -454,10 +461,10 @@ def _payperiods_preshot(self):
)
pp = BiweeklyPayPeriod.period_for_date(dtnow(), data_sess).previous
data_sess.add(Budget(
name='Budget3', is_periodic=True, starting_balance=0
name='Budget3', is_periodic=True, starting_balance=Decimal('0')
))
data_sess.add(Budget(
name='Budget4', is_periodic=True, starting_balance=0
name='Budget4', is_periodic=True, starting_balance=Decimal('0')
))
data_sess.flush()
data_sess.commit()
Expand All @@ -483,10 +490,11 @@ def _payperiods_preshot(self):
data_sess.add(Transaction(
account_id=1,
budgeted_amount=amt,
actual_amount=amt,
budget=choice(budgets),
date=pp.start_date + timedelta(days=1),
description='Transaction %d.%d' % (i, count)
description='Transaction %d.%d' % (i, count),
budget_amounts={
choice(budgets): amt
}
))
data_sess.flush()
data_sess.commit()
Expand Down Expand Up @@ -536,10 +544,11 @@ def _add_transactions(self, data_sess, pp):
data_sess.add(Transaction(
account_id=1,
budgeted_amount=amt,
actual_amount=amt,
budget=choice(budgets),
date=pp.start_date + timedelta(days=randrange(0, 12)),
description='Transaction %d' % count
description='Transaction %d' % count,
budget_amounts={
choice(budgets): amt
}
))
data_sess.flush()
data_sess.commit()
Expand Down Expand Up @@ -577,13 +586,13 @@ def _budgets_preshot(self):
)
pp = BiweeklyPayPeriod.period_for_date(dtnow(), data_sess).previous
data_sess.add(Budget(
name='Budget3', is_periodic=True, starting_balance=0
name='Budget3', is_periodic=True, starting_balance=Decimal('0')
))
data_sess.add(Budget(
name='Budget4', is_periodic=True, starting_balance=0
name='Budget4', is_periodic=True, starting_balance=Decimal('0')
))
data_sess.add(Budget(
name='Budget5', is_periodic=True, starting_balance=250
name='Budget5', is_periodic=True, starting_balance=Decimal('250')
))
data_sess.flush()
data_sess.commit()
Expand Down

0 comments on commit 8ccac42

Please sign in to comment.