def given_i_have_a_node(step): db.drop_collection("nodes") world.nodes = [] for tr in step.hashes: node = db.nodes.Node() for key, value in tr.items(): node[key] = value node.save() world.nodes.append(node)
def and_i_have_some_logs(step): world.logs = [] stream = world.streams[0] db.drop_collection(stream["log_collection"]) for tr in step.hashes: log = db[stream["log_collection"]].Log() for key, value in tr.items(): log[key] = value log.save() world.logs.append(log)
def and_i_have_a_stream(step): db.drop_collection("streams") world.streams = [] for tr in step.hashes: stream = db.streams.Stream() for key, value in tr.items(): stream[key] = value stream.node = world.nodes[0] stream.save() world.streams.append(stream)
def then_i_should_get_the_two_logs_in_the_response(step): js = json.loads(world.response.data) assert len(js) == 2 db.drop_collection(world.streams[0]["log_collection"])