예제 #1
0
def domain_users():
    user_1 = User(id=1, email="*****@*****.**", password="******")
    user_2 = User(id=2, email="*****@*****.**", password="******")
    user_3 = User(id=3, email="*****@*****.**", password="******")
    user_4 = User(id=4, email="*****@*****.**", password="******")

    return [user_1, user_2, user_3, user_4]
 def to_entity(self):
     return User(
         id=self.id,
         username=self.username,
         password=self.password,
         created_at=self.created_at,
     )
예제 #3
0
def test_user_model_init():
    USER_ID = 1
    USER_EMAIL = "*****@*****.**"
    USER_PASSWORD = "******"

    user = User(id=USER_ID, email=USER_EMAIL, password=USER_PASSWORD)
    assert user.id == USER_ID
    assert user.email == USER_EMAIL
    assert user.password == USER_PASSWORD
예제 #4
0
def test_user_model_from_dict():
    USER_ID = 1
    USER_EMAIL = "*****@*****.**"
    USER_PASSWORD = "******"

    user_dict = {"id": USER_ID, "email": USER_EMAIL, "password": USER_PASSWORD}
    user = User.from_dict(user_dict)

    assert user.id == USER_ID
    assert user.email == USER_EMAIL
    assert user.password == USER_PASSWORD
예제 #5
0
def test_serialize_domain_user():
    user = User(
        id=1,
        email='*****@*****.**',
        password='******',
    )

    expected_json = """
        {
            "id": 1,
            "email": "*****@*****.**",
            "password": "******"
        }
    """

    json_user = UserSchema().dumps(user).data
    assert json.loads(json_user) == json.loads(expected_json)
def domain_user():
    return User.from_dict(
        {"id": USER_ID, "email": USER_EMAIL, "password": USER_PASSWORD}
    )
예제 #7
0
def test_user_comparison():
    user_dict = {"user_id": 1, "email": "*****@*****.**", "password": "******"}
    user1 = User.from_dict(user_dict)
    user2 = User.from_dict(user_dict)

    assert user1 == user2
예제 #8
0
def test_user_to_dict():
    user_dict = {"id": 1, "email": "*****@*****.**", "password": "******"}
    user = User.from_dict(user_dict)
    assert user.to_dict() == user_dict
예제 #9
0
def domain_users(data_dicts):
    return [User.from_dict(d) for d in data_dicts]
예제 #10
0
    def authenticate(self, email, password):
        for d in self._data:
            if d["email"] == email and d["password"] == password:
                return User.from_dict(d)

        return None
예제 #11
0
import json
from unittest import mock

from flask import url_for

from app.core.domain.user import User

domain_user = User.from_dict({
    "id": 1,
    "email": "*****@*****.**",
    "password": "******"
})


@mock.patch("app.adaptors.UserAdaptor")
def test_get_access_token(mock_user_adaptor, client):
    mock_user_adaptor().authenticate.return_value = domain_user

    http_response = client.post(
        url_for("auth.access_token"),
        data=(json.dumps({
            "email": "*****@*****.**",
            "password": "******"
        })),
        content_type="application/json",
    )
    assert http_response.status_code == 200


@mock.patch("app.adaptors.UserAdaptor")
def test_get_access_token_with_invalid_grant(mock_user_adaptor, client):