# Path: memsource/models.py
# class BaseModel(dict):
# class User(BaseModel):
# class Authentication(BaseModel):
# class Client(BaseModel):
# class Domain(BaseModel):
# class Language(BaseModel):
# class Project(BaseModel):
# class Job(BaseModel):
# class JobPart(BaseModel):
# class TranslationMemory(BaseModel):
# class AsynchronousRequest(BaseModel):
# class AsynchronousResponse(BaseModel):
# class Segment(BaseModel):
# class SegmentSearchResult(BaseModel):
# class Analysis(BaseModel):
# class MxliffUnit(BaseModel):
# class TermBase(BaseModel):
#     def __getattr__(self, key):
#     def _iso8601_to_datetime(self, source):
#     def date_created(self):
#     def __init__(self, source):
#     def is_complete(self):
#     def has_error(self):
# 
# Path: memsource/api_rest/auth.py
# class Auth(api_rest.BaseApi):
#     def login(self, user_name: str, password: str) -> models.Authentication:


import requests
import unittest
from unittest.mock import patch
from memsource import models
from memsource.api_rest import auth



class TestAuth(unittest.TestCase):
    @patch.object(requests.Session, "request")
    def test_login(self, mock_request: unittest.mock):
        ms_response = unittest.mock.Mock(status_code=200)
        ms_response.json.return_value = {
            "user": {
                "lastName": "mock-last-name",
                "email": "mock-tm@gengo.com",
                "firstName": "mock-first-name",
                "id": "1234",
                "userName": "mock-tm",
                "role": "ADMIN",
                "uid": "QWERTY"
            },
            "token": "mock-token",
            "expires": "2020-06-19T07:31:23+0000"
        }
        mock_request.return_value = ms_response

        response = auth.Auth().login(user_name="mock-user", password="mock-password")
        self.assertIsInstance(response, models.Authentication)

# Path: memsource/models.py
# class BaseModel(dict):
# class User(BaseModel):
# class Authentication(BaseModel):
# class Client(BaseModel):
# class Domain(BaseModel):
# class Language(BaseModel):
# class Project(BaseModel):
# class Job(BaseModel):
# class JobPart(BaseModel):
# class TranslationMemory(BaseModel):
# class AsynchronousRequest(BaseModel):
# class AsynchronousResponse(BaseModel):
# class Segment(BaseModel):
# class SegmentSearchResult(BaseModel):
# class Analysis(BaseModel):
# class MxliffUnit(BaseModel):
# class TermBase(BaseModel):
#     def __getattr__(self, key):
#     def _iso8601_to_datetime(self, source):
#     def date_created(self):
#     def __init__(self, source):
#     def is_complete(self):
#     def has_error(self):
# 
# Path: memsource/api_rest/auth.py
# class Auth(api_rest.BaseApi):
#     def login(self, user_name: str, password: str) -> models.Authentication:


# Path: test/api_rest/test_auth.py
import requests
import unittest
from unittest.mock import patch
from memsource import models
from memsource.api_rest import auth




class TestAuth(unittest.TestCase):
    @patch.object(requests.Session, "request")
    def test_login(self, mock_request: unittest.mock):
        ms_response = unittest.mock.Mock(status_code=200)
        ms_response.json.return_value = {
            "user": {
                "lastName": "mock-last-name",
                "email": "mock-tm@gengo.com",
                "firstName": "mock-first-name",
                "id": "1234",
                "userName": "mock-tm",
                "role": "ADMIN",
                "uid": "QWERTY"
            },
            "token": "mock-token",
            "expires": "2020-06-19T07:31:23+0000"
        }
        mock_request.return_value = ms_response

        response = auth.Auth().login(user_name="mock-user", password="mock-password")
        self.assertIsInstance(response, models.Authentication)

        self.assertIsInstance(response["user"], models.User)