def test_remove_stale_individuals__removed_amt(setup): individual_amt = len(list(f.get_collection("individuals").stream())) removed_amt = len(list( d.query_individuals("removed", "==", True).stream())) rollover.remove_stale_individuals(2012) results = list(f.get_collection("individuals").stream()) assert len(results) == individual_amt - removed_amt, f.docs2str(results)
def test_rollover_individuals__roll_amt(setup): individual_amt = len(list(f.get_collection("individuals").stream())) roll_amt = len(list(d.query_individuals("rolled", "==", True).stream())) rollover.rollover_individuals(2012, 2013) assert (len(list( f.get_collection("individuals").stream())) == individual_amt + roll_amt)
def test_write_batch(collection): size = 30 batch = [] for i in range(size): batch.append({"id": i, "value": i}) f.write_batch(collection, "id", batch, batch_size=5) assert len(list(f.get_collection(collection).stream())) == size
def test_delete_all_individuals(): d.write_individual("u1_i1", {"user": "******"}) d.write_individual("u1_i2", {"user": "******"}) d.write_individual("u2_i1", {"user": "******"}) d.write_individual("u2_i1", {"user": "******"}) e2e.delete_user_individuals("u1") for individual in d.query_individuals("user", "==", "u1").stream(): assert False, individual for individual in f.get_collection("individuals").stream(): assert individual.to_dict()["user"] == "u2"
def test_delete_batch(collection): properties = 3 properties_size = 10 batch = [] for prop in range(properties): for prop_size in range(properties_size): batch.append({"id": (prop * properties_size + prop_size), "property": prop}) f.write_batch(collection, "id", batch) assert ( len(list(f.get_collection(collection).stream())) == properties * properties_size ) f.delete_batch(collection, "property", "==", 2, batch_size=3) results = list(f.get_collection(collection).stream()) assert len(results) == (properties - 1) * properties_size, f.docs2str(results) for result in results: assert result.to_dict().get("property") is not None assert result.to_dict()["property"] != 2
def test_get_collection(collection, doc_id, doc_id2, doc, doc2): assert doc != doc2 f.write_document(collection, doc_id, doc) f.write_document(collection, doc_id2, doc2) assert len(list(f.get_collection(collection).stream())) == 2
def test_get_collection__empty(collection): assert len(list(f.get_collection(collection).stream())) == 0