# Path: virtool/users/utils.py
# def check_password(password: str, hashed: bytes) -> bool:
#     """
#     Check if a unicode ``password`` matches a ``hashed_password``.
# 
#     :param password: the password to check.
#     :param hashed: the salted and hashed password from the database
#     :return: success of test
# 
#     """
#     return bcrypt.checkpw(password.encode(), hashed)


import pytest
from virtool.users.utils import check_password
    if error == "400_exists":
        await client.db.users.insert_one({"_id": "abc123"})

    client.app["settings"].minimum_password_length = 8

    data = {"handle": "fred", "password": "hello_world", "force_reset": False}

    if error == "400_password":
        data["password"] = "foo"

    resp = await client.post("/users", data)

    if error == "400_exists":
        await resp_is.bad_request(resp, "User already exists")
        return

    if error == "400_password":
        await resp_is.bad_request(
            resp, "Password does not meet minimum length requirement (8)"
        )
        return

    assert resp.status == 201
    assert resp.headers["Location"] == "/users/abc123"
    assert await resp.json() == snapshot

    document = await client.db.users.find_one("abc123")
    password = document.pop("password")

    assert document == snapshot

# Path: virtool/users/utils.py
# def check_password(password: str, hashed: bytes) -> bool:
#     """
#     Check if a unicode ``password`` matches a ``hashed_password``.
# 
#     :param password: the password to check.
#     :param hashed: the salted and hashed password from the database
#     :return: success of test
# 
#     """
#     return bcrypt.checkpw(password.encode(), hashed)


# Path: tests/users/test_api.py
import pytest
from virtool.users.utils import check_password

    if error == "400_exists":
        await client.db.users.insert_one({"_id": "abc123"})

    client.app["settings"].minimum_password_length = 8

    data = {"handle": "fred", "password": "hello_world", "force_reset": False}

    if error == "400_password":
        data["password"] = "foo"

    resp = await client.post("/users", data)

    if error == "400_exists":
        await resp_is.bad_request(resp, "User already exists")
        return

    if error == "400_password":
        await resp_is.bad_request(
            resp, "Password does not meet minimum length requirement (8)"
        )
        return

    assert resp.status == 201
    assert resp.headers["Location"] == "/users/abc123"
    assert await resp.json() == snapshot

    document = await client.db.users.find_one("abc123")
    password = document.pop("password")

    assert document == snapshot

    assert check_password("hello_world", password)