# Path: memsource/constants.py
# class Base(enum.Enum):
# class JobStatus(enum.Enum):
# class ProjectStatus(enum.Enum):
# class AnalysisFormat(enum.Enum):
# class TermBaseFormat(enum.Enum):
# class ApiVersion(enum.Enum):
# class HttpMethod(enum.Enum):
# class BaseRest(enum.Enum):
# class JobStatusRest(enum.Enum):
#     NEW = "New"
#     EMAILED = "Emailed"
#     ASSIGNED = "Assigned"
#     DECLINED_BY_LINGUIST = "Declined_By_Linguist"
#     COMPLETED_BY_LINGUIST = "Completed_By_Linguist"
#     COMPLETED = "Completed"
#     CANCELLED = "Cancelled"
#     NEW = "New"
#     ASSIGNED = "Assigned"
#     COMPLETED = "Completed"
#     CANCELLED = "Cancelled"
#     ACCEPTED_BY_VENDOR = "Accepted_By_Vendor"
#     DECLINED_BY_VENDOR = "Declined_By_Vendor"
#     COMPLETED_BY_VENDOR = "Completed_By_Vendor"
#     CSV = "CSV"
#     LOG = "LOG"
#     CSV_EXTENDED = "CSV_EXTENDED"
#     XLSX = "XLSX"
#     TBX = "TBX"
#     NEW = "NEW"
#     ACCEPTED = "ACCEPTED"
#     DECLINED = "DECLINED"
#     REJECTED = "REJECTED"
#     DELIVERED = "DELIVERED"
#     EMAILED = "EMAILED"
#     COMPLETED = "COMPLETED"
#     CANCELLED = "CANCELLED"
# CHUNK_SIZE = 1024
# CHAR_SET = "UTF-8"
# TM_THRESHOLD = 0.7
# 
# 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/language.py
# class Language(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Supported-Languages
# 
#     def listSupportedLangs(self) -> List[models.Language]:
#         languages = self._get("v1/languages")
#         return [models.Language(language) for language in languages.get("languages", [])]


import requests
import unittest
from unittest.mock import patch
from memsource import constants, models
from memsource.api_rest.language import Language



class TestLanguage(unittest.TestCase):
    @patch.object(requests.Session, "request")
    def test_list(self, mock_request: unittest.mock):
        ms_response = unittest.mock.MagicMock(status_code=200)
        ms_response.json.return_value = {
            "languages": [
                {"name": "Abkhaz", "code": "ab"},
                {"name": "Afar", "code": "aa"},
            ]
        }
        mock_request.return_value = ms_response

        expected = [
            models.Language(name="Abkhaz", code="ab"),

# Path: memsource/constants.py
# class Base(enum.Enum):
# class JobStatus(enum.Enum):
# class ProjectStatus(enum.Enum):
# class AnalysisFormat(enum.Enum):
# class TermBaseFormat(enum.Enum):
# class ApiVersion(enum.Enum):
# class HttpMethod(enum.Enum):
# class BaseRest(enum.Enum):
# class JobStatusRest(enum.Enum):
#     NEW = "New"
#     EMAILED = "Emailed"
#     ASSIGNED = "Assigned"
#     DECLINED_BY_LINGUIST = "Declined_By_Linguist"
#     COMPLETED_BY_LINGUIST = "Completed_By_Linguist"
#     COMPLETED = "Completed"
#     CANCELLED = "Cancelled"
#     NEW = "New"
#     ASSIGNED = "Assigned"
#     COMPLETED = "Completed"
#     CANCELLED = "Cancelled"
#     ACCEPTED_BY_VENDOR = "Accepted_By_Vendor"
#     DECLINED_BY_VENDOR = "Declined_By_Vendor"
#     COMPLETED_BY_VENDOR = "Completed_By_Vendor"
#     CSV = "CSV"
#     LOG = "LOG"
#     CSV_EXTENDED = "CSV_EXTENDED"
#     XLSX = "XLSX"
#     TBX = "TBX"
#     NEW = "NEW"
#     ACCEPTED = "ACCEPTED"
#     DECLINED = "DECLINED"
#     REJECTED = "REJECTED"
#     DELIVERED = "DELIVERED"
#     EMAILED = "EMAILED"
#     COMPLETED = "COMPLETED"
#     CANCELLED = "CANCELLED"
# CHUNK_SIZE = 1024
# CHAR_SET = "UTF-8"
# TM_THRESHOLD = 0.7
# 
# 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/language.py
# class Language(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Supported-Languages
# 
#     def listSupportedLangs(self) -> List[models.Language]:
#         languages = self._get("v1/languages")
#         return [models.Language(language) for language in languages.get("languages", [])]


# Path: test/api_rest/test_language.py
import requests
import unittest
from unittest.mock import patch
from memsource import constants, models
from memsource.api_rest.language import Language




class TestLanguage(unittest.TestCase):
    @patch.object(requests.Session, "request")
    def test_list(self, mock_request: unittest.mock):
        ms_response = unittest.mock.MagicMock(status_code=200)
        ms_response.json.return_value = {
            "languages": [
                {"name": "Abkhaz", "code": "ab"},
                {"name": "Afar", "code": "aa"},
            ]
        }
        mock_request.return_value = ms_response

        expected = [
            models.Language(name="Abkhaz", code="ab"),

            models.Language(name="Afar", code="aa"),