# 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/analysis.py
# class Analysis(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Analysis
# 
#     def get(self, analysis_id: int) -> models.Analysis:
#         """Call get API.
# 
#         :param analysis_id: Get analysis of this id.
#         :return: Result of analysis.
#         """
#         return models.Analysis(self._get("v3/analyses/{}".format(analysis_id)))
# 
#     def create(self, jobs: List[int]) -> models.AsynchronousRequest:
#         """Create new analysis.
# 
#         :param jobs: Target of analysis.
#         :return: Result of analysis.
#         """
#         return models.AsynchronousRequest(self._post("v2/analyses", {
#             "jobs": [{"uid": job} for job in jobs],
#         }))
# 
#     def delete(self, analysis_id: int, purge: bool=False) -> None:
#         """Delete an analysis.
# 
#         :param analysis_id: Analysis ID you want to delete.
#         :param purge:
#         """
#         self._delete("v1/analyses/{}".format(analysis_id), {"purge": purge})
# 
#     def get_by_project(self, project_id: str) -> List[models.Analysis]:
#         """List Analyses By Project.
# 
#         :param project_id: Project ID for which you want to get the analyses.
#         :return: List of Analyses.
#         """
#         project_analyses = self._get("v2/projects/{}/analyses".format(project_id))
#         return [models.Analysis(analysis) for analysis in project_analyses["content"]]
# 
#     def download(
#             self,
#             analysis_id: int,
#             dest_file_path: str,
#             file_format: constants.AnalysisFormat=constants.AnalysisFormat.CSV,
#     ) -> None:
#         """Download analysis into specified file format.
# 
#         :param analysis_id: Anaylsis ID for which you download.
#         :param dest_file_path: Destination path where you want to download the file.
#         :param file_format: File format of file.
#         :return: Downloaded file with content of the analysis
#         """
#         with open(dest_file_path, "wb") as f:
#             for chunk in self._get_analysis_stream(analysis_id, file_format):
#                 f.write(chunk)
# 
#     def _get_analysis_stream(
#             self,
#             analysis_id: int,
#             file_format: constants.AnalysisFormat
#     ) -> Iterator[bytes]:
#         """Process bytes return by API
# 
#         :param analysis_id: Anaylsis ID for which you download.
#         :param file_format: File format of file.
#         :return: Downloaded analysis file with iterator.
#         """
#         return self._get_stream("v1/analyses/{}/download".format(analysis_id), {
#             "format": file_format.value,
#         }).iter_content(constants.CHUNK_SIZE)


import requests
import unittest
from unittest.mock import patch, PropertyMock
from memsource import constants, models
from memsource.api_rest.analysis import Analysis
            "content": [
                {
                    "id": "1",
                    "type": "PreAnalyse",
                    "name": "analysis",
                    "provider": {},
                    "createdBy": {},
                    "dateCreated": "2014-11-03T16:03:11Z",
                    "netRateScheme": {},
                    "analyseLanguageParts": [],
                },
                {
                    "id": "2",
                    "type": "PreAnalyse",
                    "name": "analysis-2",
                    "provider": {},
                    "createdBy": {},
                    "dateCreated": "2014-11-03T16:03:11Z",
                    "netRateScheme": {},
                    "analyseLanguageParts": [],
                }
            ]
        }

        project_id = 1234

        analyses = Analysis(token="mock-token").get_by_project(project_id)

        self.assertIsInstance(analyses, list)
        for analysis in analyses:

# 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/analysis.py
# class Analysis(api_rest.BaseApi):
#     # Document: https://cloud.memsource.com/web/docs/api#tag/Analysis
# 
#     def get(self, analysis_id: int) -> models.Analysis:
#         """Call get API.
# 
#         :param analysis_id: Get analysis of this id.
#         :return: Result of analysis.
#         """
#         return models.Analysis(self._get("v3/analyses/{}".format(analysis_id)))
# 
#     def create(self, jobs: List[int]) -> models.AsynchronousRequest:
#         """Create new analysis.
# 
#         :param jobs: Target of analysis.
#         :return: Result of analysis.
#         """
#         return models.AsynchronousRequest(self._post("v2/analyses", {
#             "jobs": [{"uid": job} for job in jobs],
#         }))
# 
#     def delete(self, analysis_id: int, purge: bool=False) -> None:
#         """Delete an analysis.
# 
#         :param analysis_id: Analysis ID you want to delete.
#         :param purge:
#         """
#         self._delete("v1/analyses/{}".format(analysis_id), {"purge": purge})
# 
#     def get_by_project(self, project_id: str) -> List[models.Analysis]:
#         """List Analyses By Project.
# 
#         :param project_id: Project ID for which you want to get the analyses.
#         :return: List of Analyses.
#         """
#         project_analyses = self._get("v2/projects/{}/analyses".format(project_id))
#         return [models.Analysis(analysis) for analysis in project_analyses["content"]]
# 
#     def download(
#             self,
#             analysis_id: int,
#             dest_file_path: str,
#             file_format: constants.AnalysisFormat=constants.AnalysisFormat.CSV,
#     ) -> None:
#         """Download analysis into specified file format.
# 
#         :param analysis_id: Anaylsis ID for which you download.
#         :param dest_file_path: Destination path where you want to download the file.
#         :param file_format: File format of file.
#         :return: Downloaded file with content of the analysis
#         """
#         with open(dest_file_path, "wb") as f:
#             for chunk in self._get_analysis_stream(analysis_id, file_format):
#                 f.write(chunk)
# 
#     def _get_analysis_stream(
#             self,
#             analysis_id: int,
#             file_format: constants.AnalysisFormat
#     ) -> Iterator[bytes]:
#         """Process bytes return by API
# 
#         :param analysis_id: Anaylsis ID for which you download.
#         :param file_format: File format of file.
#         :return: Downloaded analysis file with iterator.
#         """
#         return self._get_stream("v1/analyses/{}/download".format(analysis_id), {
#             "format": file_format.value,
#         }).iter_content(constants.CHUNK_SIZE)


# Path: test/api_rest/test_analysis.py
import requests
import unittest
from unittest.mock import patch, PropertyMock
from memsource import constants, models
from memsource.api_rest.analysis import Analysis

            "content": [
                {
                    "id": "1",
                    "type": "PreAnalyse",
                    "name": "analysis",
                    "provider": {},
                    "createdBy": {},
                    "dateCreated": "2014-11-03T16:03:11Z",
                    "netRateScheme": {},
                    "analyseLanguageParts": [],
                },
                {
                    "id": "2",
                    "type": "PreAnalyse",
                    "name": "analysis-2",
                    "provider": {},
                    "createdBy": {},
                    "dateCreated": "2014-11-03T16:03:11Z",
                    "netRateScheme": {},
                    "analyseLanguageParts": [],
                }
            ]
        }

        project_id = 1234

        analyses = Analysis(token="mock-token").get_by_project(project_id)

        self.assertIsInstance(analyses, list)
        for analysis in analyses:

            self.assertIsInstance(analysis, models.Analysis)