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
46 lines (35 loc) · 1.12 KB
/
debug.py
File metadata and controls
46 lines (35 loc) · 1.12 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Company, Dev, Freebie, Base
def debug_session():
engine = create_engine('sqlite:///freebies.db')
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()
company = Company(name="TestCorp", founding_year=2005)
dev = Dev(name="TestDev")
session.add_all([company, dev])
session.commit()
freebie = Freebie(
item_name="TestItem",
value=50,
company=company,
dev=dev
)
session.add(freebie)
session.commit()
print("Test objects created:")
print(f"- company: {company}")
print(f"- dev: {dev}")
print(f"- freebie: {freebie}")
print("\nTry these commands:")
print("freebie.print_details()")
print("company.freebies")
print("dev.companies")
print("Company.oldest_company(session)")
print("dev.received_one('TestItem')")
print("dev.give_away(other_dev, freebie, session)")
import ipdb; ipdb.set_trace()
if __name__ == '__main__':
debug_session()