コード例 #1
0
def test_insert_loan(loan_fixture, snapshot):
    test_db = mongomock.MongoClient()["Test"]
    db = Database(test_db)
    loan = parse_model_and_validate(loan_fixture, Loan)
    snapshot.assert_match(loan.status)
    snapshot.assert_match(loan.data)

    db._insert_loan(loan.data)
    loan_inserted = db.find_loan(loan_fixture["_id"])

    snapshot.assert_match(loan_inserted)
コード例 #2
0
def test_delete_loan_and_cliente(loan_fixture, client_fixture, snapshot):
    test_db = mongomock.MongoClient()["Test"]
    db = Database(test_db)
    loan_id = loan_fixture["_id"]
    client_id = client_fixture["_id"]

    assert loan_id == client_id

    db._insert_client(client_fixture)
    db._insert_loan(loan_fixture)

    loan = db.find_loan(loan_id)
    client = db.find_client(client_id)

    snapshot.assert_match(loan)
    snapshot.assert_match(client)

    db.delete_loan_and_client(client_id)

    loan = db.find_loan(loan_id)
    client = db.find_client(client_id)

    snapshot.assert_match(loan)
    snapshot.assert_match(client)