The new command ImportCommand takes a Serializable type, from which it can call the deserialize method to generate a DB ORM type. The Serializable interface also declares the serialize method. (De)serialization moved to the ORM types, due to the inability to properly use overloading. Possible improvement for the future is to merge serialization information on JSONDecoder/Encoder classes. Adds a MockClient with the in-memory SQLite DB which can be used by tests. Most types export/import functionally tested using two DBs and comparing entries.
22 lines
526 B
Python
22 lines
526 B
Python
from decimal import Decimal
|
|
|
|
from pfbudget.db.model import Category, CategoryGroup, CategoryRule, Tag, TagRule
|
|
|
|
category_null = Category("null")
|
|
|
|
categorygroup1 = CategoryGroup("group#1")
|
|
|
|
category1 = Category(
|
|
"cat#1",
|
|
"group#1",
|
|
rules=[CategoryRule("cat#1", description="desc#1", max=Decimal(0))],
|
|
)
|
|
|
|
category2 = Category(
|
|
"cat#2",
|
|
"group#1",
|
|
rules=[CategoryRule("cat#1", description="desc#1", max=Decimal(0))],
|
|
)
|
|
|
|
tag_1 = Tag("tag#1", rules=[TagRule("tag#1", description="desc#1", max=Decimal(0))])
|