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
30 lines (23 loc) · 1009 Bytes
/
debug.py
File metadata and controls
30 lines (23 loc) · 1009 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
25
26
27
28
29
30
#!/usr/bin/env python3
from models import Company, Dev, Freebie
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
if __name__ == '__main__':
engine = create_engine('sqlite:///freebies.db')
Session = sessionmaker(bind=engine)
session = Session()
# Retrieve objects
dev = session.query(Dev).filter_by(name="Silvia").first()
company = session.query(Company).filter_by(name="Apple").first()
# Test received_one()
print(dev.received_one("Laptop")) # output: True
print(dev.received_one("Tablet")) # output: False
# Test give_away()
freebie = session.query(Freebie).filter_by(item_name="Laptop").first()
dev.give_away(session.query(Dev).filter_by(name="Eugene").first(), freebie)
session.commit()
# Test print_details()
print(freebie.print_details()) # Should show Bob owns a Laptop from Google
# Test oldest_company()
print(Company.oldest_company(session)) #output: microsoft
import ipdb; ipdb.set_trace()