# 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/project.py
# class Project(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Project
# 
#     def create(
#         self,
#         name: str,
#         source_lang: str,
#         target_langs: List[str],
#         client: int=None,
#         domain: int=None,
#     ) -> int:
#         return self._post("v1/projects", {
#             "name": name,
#             "sourceLang": source_lang,
#             "targetLangs": target_langs,
#             "client": client,
#             "domain": domain,
#         })["id"]
# 
#     def list(self, **query) -> List[models.Project]:
#         projects = self._get("v1/projects", query)
#         return [models.Project(project) for project in projects.get("content", [])]
# 
#     def get_trans_memories(self, project_id: int) -> List[models.TranslationMemory]:
#         translation_memories = self._get("v1/projects/{}/transMemories".format(project_id))
#         return [
#             models.TranslationMemory(tm)
#             for tm in translation_memories.get("transMemories", [])
#         ]
# 
#     def set_trans_memories(
#         self,
#         project_id: int,
#         translation_memories: List[Dict[str, Any]],
#         target_lang: str=None,
#         workflow_step: Optional[Dict[str, str]]=None,
#     ) -> None:
#         """You can set translation memory to a project.
# 
#         :param project_id: set translation memory to this id of project
#         :param translation_memories: Read/Write to these translation memories
#         :param target_lang: set translation memories only for the specific project target language
#         """
#         params = {"transMemories": translation_memories}
# 
#         if target_lang is not None:
#             params["targetLang"] = target_lang
# 
#         if workflow_step is not None:
#             params["workflowStep"] = workflow_step
# 
#         # This end-point return nothing.
#         self._put("v2/projects/{}/transMemories".format(project_id), params)
# 
#     def set_status(self, project_id: int, status: constants.ProjectStatus) -> None:
#         """Update project status
# 
#         ProjectStatus: New, Emailed, Assigned, Declined_By_Linguist,
#                        Completed_By_Linguist, Completed, Cancelled
# 
#         :param project_id: id of project you want to update.
#         :param status: status of project to update. Acceptable type is ProjectStatus constant.
#         """
# 
#         self._post("v1/projects/{}/setStatus".format(project_id), {
#             "status": status.value.upper()
#         })
# 
#     def get_term_bases(self, project_id: int) -> List[models.TermBase]:
#         """Returns the list of term bases belonging to a project.
#         :param project_id: ID of the project containing the term bases
#         """
#         term_bases = self._get("v1/projects/{}/termBases".format(project_id))
#         return [models.TermBase(term_base) for term_base in term_bases.get("termBases", [])]


import requests
import unittest
from unittest.mock import patch
from memsource import constants, models
from memsource.api_rest.project import Project



class TestProject(unittest.TestCase):
    @patch.object(requests.Session, "request")
    def test_create(self, mock_request: unittest.mock):
        ms_response = unittest.mock.MagicMock(status_code=200)
        ms_response.json.return_value = {
            "uid": "1234",
            "internalId": 0,
            "id": "1234",
            "name": "mock-project",
            "dateCreated": "2020-06-22T01:44:04Z",
            "domain": {"name": "mock-domain", "id": "1"},
            "sourceLang": "en",
            "targetLangs": ["ja", "de"],
        }
        mock_request.return_value = ms_response


# 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/project.py
# class Project(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Project
# 
#     def create(
#         self,
#         name: str,
#         source_lang: str,
#         target_langs: List[str],
#         client: int=None,
#         domain: int=None,
#     ) -> int:
#         return self._post("v1/projects", {
#             "name": name,
#             "sourceLang": source_lang,
#             "targetLangs": target_langs,
#             "client": client,
#             "domain": domain,
#         })["id"]
# 
#     def list(self, **query) -> List[models.Project]:
#         projects = self._get("v1/projects", query)
#         return [models.Project(project) for project in projects.get("content", [])]
# 
#     def get_trans_memories(self, project_id: int) -> List[models.TranslationMemory]:
#         translation_memories = self._get("v1/projects/{}/transMemories".format(project_id))
#         return [
#             models.TranslationMemory(tm)
#             for tm in translation_memories.get("transMemories", [])
#         ]
# 
#     def set_trans_memories(
#         self,
#         project_id: int,
#         translation_memories: List[Dict[str, Any]],
#         target_lang: str=None,
#         workflow_step: Optional[Dict[str, str]]=None,
#     ) -> None:
#         """You can set translation memory to a project.
# 
#         :param project_id: set translation memory to this id of project
#         :param translation_memories: Read/Write to these translation memories
#         :param target_lang: set translation memories only for the specific project target language
#         """
#         params = {"transMemories": translation_memories}
# 
#         if target_lang is not None:
#             params["targetLang"] = target_lang
# 
#         if workflow_step is not None:
#             params["workflowStep"] = workflow_step
# 
#         # This end-point return nothing.
#         self._put("v2/projects/{}/transMemories".format(project_id), params)
# 
#     def set_status(self, project_id: int, status: constants.ProjectStatus) -> None:
#         """Update project status
# 
#         ProjectStatus: New, Emailed, Assigned, Declined_By_Linguist,
#                        Completed_By_Linguist, Completed, Cancelled
# 
#         :param project_id: id of project you want to update.
#         :param status: status of project to update. Acceptable type is ProjectStatus constant.
#         """
# 
#         self._post("v1/projects/{}/setStatus".format(project_id), {
#             "status": status.value.upper()
#         })
# 
#     def get_term_bases(self, project_id: int) -> List[models.TermBase]:
#         """Returns the list of term bases belonging to a project.
#         :param project_id: ID of the project containing the term bases
#         """
#         term_bases = self._get("v1/projects/{}/termBases".format(project_id))
#         return [models.TermBase(term_base) for term_base in term_bases.get("termBases", [])]


# Path: test/api_rest/test_project.py
import requests
import unittest
from unittest.mock import patch
from memsource import constants, models
from memsource.api_rest.project import Project




class TestProject(unittest.TestCase):
    @patch.object(requests.Session, "request")
    def test_create(self, mock_request: unittest.mock):
        ms_response = unittest.mock.MagicMock(status_code=200)
        ms_response.json.return_value = {
            "uid": "1234",
            "internalId": 0,
            "id": "1234",
            "name": "mock-project",
            "dateCreated": "2020-06-22T01:44:04Z",
            "domain": {"name": "mock-domain", "id": "1"},
            "sourceLang": "en",
            "targetLangs": ["ja", "de"],
        }
        mock_request.return_value = ms_response


        response = Project(token="mock-token").create(