# 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/api_rest/term_base.py
# class TermBase(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Term-Base
# 
#     def download(
#         self,
#         termbase_id: int,
#         filepath: str,
#         file_format: constants.TermBaseFormat=constants.TermBaseFormat.XLSX,
#         chunk_size: int=constants.CHUNK_SIZE,
#         charset: str=constants.CHAR_SET,
#     ) -> None:
#         """Download a term base.
# 
#         :param termbase_id: ID of the term base to be downloaded.
#         :param filepath: Save exported data to this file path.
#         :param file_format: TBX or XLSX. Defaults to XLSX.
#         :param chunk_size: byte size of chunk for response data.
#         """
#         params = {
#             "format": file_format.value.capitalize(),
#             "charset": charset,
#         }
# 
#         with open(filepath, 'wb') as f:
#             data_stream = self._get_stream(
#                 "v1/termBases/{}/export".format(termbase_id), params
#             ).iter_content(chunk_size)
# 
#             for chunk in data_stream:
#                 f.write(chunk)


import requests
import unittest
from unittest.mock import patch
from memsource import constants
from memsource.api_rest.term_base import TermBase



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

# 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/api_rest/term_base.py
# class TermBase(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Term-Base
# 
#     def download(
#         self,
#         termbase_id: int,
#         filepath: str,
#         file_format: constants.TermBaseFormat=constants.TermBaseFormat.XLSX,
#         chunk_size: int=constants.CHUNK_SIZE,
#         charset: str=constants.CHAR_SET,
#     ) -> None:
#         """Download a term base.
# 
#         :param termbase_id: ID of the term base to be downloaded.
#         :param filepath: Save exported data to this file path.
#         :param file_format: TBX or XLSX. Defaults to XLSX.
#         :param chunk_size: byte size of chunk for response data.
#         """
#         params = {
#             "format": file_format.value.capitalize(),
#             "charset": charset,
#         }
# 
#         with open(filepath, 'wb') as f:
#             data_stream = self._get_stream(
#                 "v1/termBases/{}/export".format(termbase_id), params
#             ).iter_content(chunk_size)
# 
#             for chunk in data_stream:
#                 f.write(chunk)


# Path: test/api_rest/test_term_base.py
import requests
import unittest
from unittest.mock import patch
from memsource import constants
from memsource.api_rest.term_base import TermBase




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

    def test_download(self, mock_request: unittest.mock, mock_open: unittest.mock.MagicMock):