2 from core.deptools import *
3 from breakfast import *
5 # Pure python defined item test code
7 # Tests that we can define items in pure python code and have the marshallers
8 # convert it back and forth several times to simple dicts and JSON without
9 # any loss of information
11 # THIS IS NOT AN EXAMPLE OF GENERAL USAGE!
13 # TODO: Move this into unit testing
15 coffee_drinker = breakfast_task_factory.task_from_requirements( ('coffee','hugs') )
16 caffeine_free = breakfast_task_factory.task_from_requirements( ('hugs',) )
18 ds = DigraphDependencyStrategy
21 for item in ds.iterate_item_dependencies(coffee_drinker.goal):
26 for item in ds.iterate_item_dependencies(caffeine_free.goal):
35 print "\nconverting breakfast task to json:"
36 ic = core.marshal.ItemConverter()
37 objitems = map(ic.itemclass_to_itemdict, breakfast_task_factory.classes)
39 jsondata = json.dumps(objitems)
43 print "\nimporting back in"
44 task_factory = lib.loaders.JSONItemLoader.load_item_classes_from_string(jsondata)
45 for c in task_factory.classes:
48 print "\nand back again"
49 objitems = map(ic.itemclass_to_itemdict, breakfast_task_factory.classes)
50 jsondata = json.dumps(objitems)
51 task_factory = lib.loaders.JSONItemLoader.load_item_classes_from_string(jsondata)
53 print "\nNow trying another pruning example:"
54 another_caffeine_free = task_factory.task_from_requirements( [] )
55 for item in ds.iterate_item_dependencies(another_caffeine_free.goal):