forked from learn-co-curriculum/python-p3-freebie-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
24 lines (18 loc) · 772 Bytes
/
debug.py
File metadata and controls
24 lines (18 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from models import session, Dev, Company, Freebie
# Example tests
alice = session.query(Dev).filter_by(name="Alice").first()
bob = session.query(Dev).filter_by(name="Bob").first()
hackcorp = session.query(Company).filter_by(name="HackCorp").first()
# Print Alice's freebies
for freebie in alice.freebies:
print(freebie.print_details())
# Check if Alice received a Sticker
print("Received Sticker?", alice.received_one("Sticker")) # True
# Oldest company
print("Oldest company:", Company.oldest_company().name) # CodeLabs
# Give away a freebie
freebie_to_give = alice.freebies[0]
alice.give_away(bob, freebie_to_give)
print(freebie_to_give.print_details()) # Now belongs to Bob
# Check company devs
print("HackCorp devs:", [dev.name for dev in hackcorp.devs])