# 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/bilingual.py
# class Bilingual(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Bilingual-File
# 
#     def _get_bilingual_stream(self, project_id: int, job_uids: List[str]) -> Iterator[bytes]:
#         """Common process of bilingualFile.
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :return: Downloaded bilingual file with iterator.
#         """
#         return self._post_stream(
#             path="v1/projects/{}/jobs/bilingualFile".format(project_id),
#             data={"jobs": [{"uid": job_uid} for job_uid in job_uids]},
#         ).iter_content(constants.CHUNK_SIZE)
# 
#     def get_bilingual_file_xml(self, project_id: int, job_uids: List[str]) -> bytes:
#         """Download bilingual file and return it as bytes.
# 
#         This method might use huge memory.
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :return: Downloaded bilingual file.
#         """
#         buffer = io.BytesIO()
# 
#         for chunk in self._get_bilingual_stream(project_id, job_uids):
#             buffer.write(chunk)
# 
#         return buffer.getvalue()
# 
#     def get_bilingual_file(
#             self,
#             project_id: int,
#             job_uids: List[int],
#             dest_file_path: str
#     ) -> None:
#         """Download bilingual file and save it as a file.
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :param dest_file_path: Save bilingual file to there.
#         """
#         with open(dest_file_path, "wb") as f:
#             for chunk in self._get_bilingual_stream(project_id, job_uids):
#                 f.write(chunk)
# 
#     def get_bilingual_as_mxliff_units(
#             self,
#             project_id: int,
#             job_uids: List[str]
#     ) -> models.MxliffUnit:
#         """Download bilingual file and parse it as [models.MxliffUnit]
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :returns: MxliffUnit
#         """
#         return mxliff.MxliffParser().parse(self.get_bilingual_file_xml(project_id, job_uids))
# 
#     def upload_bilingual_file_from_xml(self, xml: str) -> List[models.Job]:
#         """Call uploadBilingualFile API.
# 
#         :param xml: Upload this file.
#         """
#         extra_headers = {"Content-Type": "application/octet-stream"}
#         self.add_headers(extra_headers)
# 
#         self._put("v1/bilingualFiles", None, {
#             "file": ("{}.mxliff".format(uuid.uuid1().hex), xml),
#         })


import os
import requests
import unittest
import uuid
from unittest.mock import patch, PropertyMock
from memsource import constants, models
from memsource.api_rest.bilingual import Bilingual



class TestBilingual(unittest.TestCase):
    @patch("builtins.open")
    @patch.object(requests.Session, "request")
    def test_get_bilingual_file(

# 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/bilingual.py
# class Bilingual(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Bilingual-File
# 
#     def _get_bilingual_stream(self, project_id: int, job_uids: List[str]) -> Iterator[bytes]:
#         """Common process of bilingualFile.
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :return: Downloaded bilingual file with iterator.
#         """
#         return self._post_stream(
#             path="v1/projects/{}/jobs/bilingualFile".format(project_id),
#             data={"jobs": [{"uid": job_uid} for job_uid in job_uids]},
#         ).iter_content(constants.CHUNK_SIZE)
# 
#     def get_bilingual_file_xml(self, project_id: int, job_uids: List[str]) -> bytes:
#         """Download bilingual file and return it as bytes.
# 
#         This method might use huge memory.
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :return: Downloaded bilingual file.
#         """
#         buffer = io.BytesIO()
# 
#         for chunk in self._get_bilingual_stream(project_id, job_uids):
#             buffer.write(chunk)
# 
#         return buffer.getvalue()
# 
#     def get_bilingual_file(
#             self,
#             project_id: int,
#             job_uids: List[int],
#             dest_file_path: str
#     ) -> None:
#         """Download bilingual file and save it as a file.
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :param dest_file_path: Save bilingual file to there.
#         """
#         with open(dest_file_path, "wb") as f:
#             for chunk in self._get_bilingual_stream(project_id, job_uids):
#                 f.write(chunk)
# 
#     def get_bilingual_as_mxliff_units(
#             self,
#             project_id: int,
#             job_uids: List[str]
#     ) -> models.MxliffUnit:
#         """Download bilingual file and parse it as [models.MxliffUnit]
# 
#         :param project_id: ID of the project.
#         :param job_uids: List of job uids.
#         :returns: MxliffUnit
#         """
#         return mxliff.MxliffParser().parse(self.get_bilingual_file_xml(project_id, job_uids))
# 
#     def upload_bilingual_file_from_xml(self, xml: str) -> List[models.Job]:
#         """Call uploadBilingualFile API.
# 
#         :param xml: Upload this file.
#         """
#         extra_headers = {"Content-Type": "application/octet-stream"}
#         self.add_headers(extra_headers)
# 
#         self._put("v1/bilingualFiles", None, {
#             "file": ("{}.mxliff".format(uuid.uuid1().hex), xml),
#         })


# Path: test/api_rest/test_bilingual.py
import os
import requests
import unittest
import uuid
from unittest.mock import patch, PropertyMock
from memsource import constants, models
from memsource.api_rest.bilingual import Bilingual




class TestBilingual(unittest.TestCase):
    @patch("builtins.open")
    @patch.object(requests.Session, "request")
    def test_get_bilingual_file(

            self,