Esempio n. 1
0
def test_find_one_accepts_argument_to_encrypt_fields():
    """Tests that the Store's find_one method will accept an encrypt_list
    parameter and that any field named in the list will be encrypted
    with password."""
    store = _create_store()
    record = store.find_one({"that": "foo"}, encrypt_list=["this"], password="******")
    assert record["this"] != store.find_one({"that": "foo"})["this"]
    assert decrypt(record["this"], key="password") == store.find_one({"that": "foo"})["this"]
Esempio n. 2
0
def test_find_one_accepts_argument_to_encrypt_fields():
    """Tests that the Store's find_one method will accept an encrypt_list
    parameter and that any field named in the list will be encrypted
    with password."""
    store = _create_store()
    record = store.find_one({"that": "foo"},
                            encrypt_list=["this"],
                            password="******")
    assert record["this"] != store.find_one({"that": "foo"})["this"]
    assert decrypt(record["this"],
                   key="password") == store.find_one({"that": "foo"})["this"]
Esempio n. 3
0
def test_find_one_only_returns_one_record():
    """Tests that the Store's find_one method will only
    return one record."""
    store = _create_store()

    result = store.find_one({"this": "that"})
    assert isinstance(result, dict)
Esempio n. 4
0
def test_find_one_only_returns_one_record():
    """Tests that the Store's find_one method will only
    return one record."""
    store = _create_store()

    result = store.find_one({"this": "that"})
    assert isinstance(result, dict)
Esempio n. 5
0
def test_find_and_find_one_accept_compiled_regex():
    """Tests that the Store's methods find and find_one will
    accept a compiled regex and will then match records where
    the regex matches."""
    import re
    store = _create_store()
    regex = re.compile("t.*")
    results = store.find({"this": regex})
    result = [store.find_one({"this": regex})]
    assert len(results) == 3
    assert len(result) == 1
Esempio n. 6
0
def test_find_and_find_one_accept_compiled_regex():
    """Tests that the Store's methods find and find_one will
    accept a compiled regex and will then match records where
    the regex matches."""
    import re

    store = _create_store()
    regex = re.compile("t.*")
    results = store.find({"this": regex})
    result = [store.find_one({"this": regex})]
    assert len(results) == 3
    assert len(result) == 1
Esempio n. 7
0
def test_find_and_find_one_accept_sanitize_list_argument_and_sanitizes_those_fields():
    """Tests that the Store's methods find and find_one will accept a
    parameter called sanitize_list and that any field named in the list
    will be sanitized (ie the value of that field will be replaced with
    8 asterics [*])"""
    store = _create_store()
    results = store.find({"this": "that"}, sanitize_list=["this"])
    print "RESULTS: ", results
    print "STORE:", store
    for result in results:
        assert result["this"] == "*" * 8
    result = store.find_one({"this": "that"}, sanitize_list=["this"])
    print "RESULT:", result
    assert result["this"] == "*" * 8
Esempio n. 8
0
def test_find_and_find_one_accept_sanitize_list_argument_and_sanitizes_those_fields(
):
    """Tests that the Store's methods find and find_one will accept a
    parameter called sanitize_list and that any field named in the list
    will be sanitized (ie the value of that field will be replaced with
    8 asterics [*])"""
    store = _create_store()
    results = store.find({"this": "that"}, sanitize_list=["this"])
    print "RESULTS: ", results
    print "STORE:", store
    for result in results:
        assert result["this"] == "*" * 8
    result = store.find_one({"this": "that"}, sanitize_list=["this"])
    print "RESULT:", result
    assert result["this"] == "*" * 8
Esempio n. 9
0
def test_each_record_gets_uuid():
    """tests that each record gets a unique  uuid in the '_id'"""
    store = data.store.Store()
    store.add_record({"this": "that"})
    rec = store.find_one({"this": "that"})
    assert "_id" in rec
Esempio n. 10
0
def test_each_record_gets_uuid():
    """tests that each record gets a unique  uuid in the '_id'"""
    store = data.store.Store()
    store.add_record({"this": "that"})
    rec = store.find_one({"this": "that"})
    assert "_id" in rec