import domain import knot # container bootstrap container = knot.Container({'db.fqn': 'sqlite:///:memory:', 'db.echo': False}) domain.apply_to_container(container) # Plain case user_repository = container('models_user_repository') # insert user = user_repository.new(email='*****@*****.**') user.first_name = 'Maximo' user.password = '******' user_repository.insert(user) print 'User created with id %d' % user.id # find query = user_repository.create_query().\ find_by_email('*****@*****.**').\ find_active() found = user_repository.find(query).one() print 'User %s was created at %s' % (found.email, found.created_at) # delete user_repository.delete(found) found = user_repository.find(query).all() if len(found) == 0: print 'Deleted success!'
def container(): settings = config.read_ini('tests/integration/config/test.ini') container = knot.Container(settings=settings) containers.setup(container) return container
def create_save_usecase(config_path): settings = config.read_ini(config_path) container = knot.Container(settings=settings) containers.setup(container) return container('usecases.save_charges_from_json')
def create_save_usecase(config_path): settings = config.read_ini(config_path) container = knot.Container(settings=settings) containers.setup(container) return container('usecases.clean_up_and_results')