# Path: prestans/types/binary_response.py
# class BinaryResponse(object):
#     """
#     Body Response Template to transfer binary files.
#     """
# 
#     def __init__(self, mime_type=None, file_name=None, as_attachment=True, contents=None):
# 
#         self.mime_type = mime_type
#         self.file_name = file_name
# 
#         self._as_attachment = as_attachment
#         self._contents = contents
# 
#     @property
#     def mime_type(self):
#         return self._mime_type
# 
#     @mime_type.setter
#     def mime_type(self, value):
#         self._mime_type = value
# 
#     @property
#     def file_name(self):
#         return self._file_name
# 
#     @file_name.setter
#     def file_name(self, value):
#         self._file_name = value
# 
#     @property
#     def as_attachment(self):
#         return self._as_attachment
# 
#     @as_attachment.setter
#     def as_attachment(self, value):
#         self._as_attachment = value
# 
#     @property
#     def contents(self):
#         return self._contents
# 
#     @contents.setter
#     def contents(self, value):
#         self._contents = value
# 
#     @property
#     def content_length(self):
#         if self._contents is None:
#             return 0
#         return len(self._contents)
# 
#     def validate(self):
#         return self._mime_type is not None and \
#                self._file_name is not None and \
#                self.content_length > 0


import unittest
from prestans.types import BinaryResponse
    def test_file_name(self):
        binary_response = BinaryResponse()
        self.assertIsNone(binary_response.file_name)

        file_name_a = "file.csv"
        binary_response = BinaryResponse(file_name=file_name_a)
        self.assertEqual(binary_response.file_name, file_name_a)

        file_name_b = "file.txt"
        binary_response = BinaryResponse()
        self.assertIsNone(binary_response.file_name)
        binary_response.file_name = file_name_b
        self.assertEqual(binary_response.file_name, file_name_b)

    def test_as_attachment(self):
        binary_response = BinaryResponse()
        self.assertTrue(binary_response.as_attachment)

        binary_response.as_attachment = False
        self.assertFalse(binary_response.as_attachment)

    def test_contents(self):
        binary_response = BinaryResponse()
        self.assertIsNone(binary_response.contents)

        contents = "contents of binary response"
        binary_response.contents = contents
        self.assertEqual(binary_response.contents, contents)

    def test_content_length(self):

# Path: prestans/types/binary_response.py
# class BinaryResponse(object):
#     """
#     Body Response Template to transfer binary files.
#     """
# 
#     def __init__(self, mime_type=None, file_name=None, as_attachment=True, contents=None):
# 
#         self.mime_type = mime_type
#         self.file_name = file_name
# 
#         self._as_attachment = as_attachment
#         self._contents = contents
# 
#     @property
#     def mime_type(self):
#         return self._mime_type
# 
#     @mime_type.setter
#     def mime_type(self, value):
#         self._mime_type = value
# 
#     @property
#     def file_name(self):
#         return self._file_name
# 
#     @file_name.setter
#     def file_name(self, value):
#         self._file_name = value
# 
#     @property
#     def as_attachment(self):
#         return self._as_attachment
# 
#     @as_attachment.setter
#     def as_attachment(self, value):
#         self._as_attachment = value
# 
#     @property
#     def contents(self):
#         return self._contents
# 
#     @contents.setter
#     def contents(self, value):
#         self._contents = value
# 
#     @property
#     def content_length(self):
#         if self._contents is None:
#             return 0
#         return len(self._contents)
# 
#     def validate(self):
#         return self._mime_type is not None and \
#                self._file_name is not None and \
#                self.content_length > 0


# Path: tests/types/test_binary_response.py
import unittest
from prestans.types import BinaryResponse

    def test_file_name(self):
        binary_response = BinaryResponse()
        self.assertIsNone(binary_response.file_name)

        file_name_a = "file.csv"
        binary_response = BinaryResponse(file_name=file_name_a)
        self.assertEqual(binary_response.file_name, file_name_a)

        file_name_b = "file.txt"
        binary_response = BinaryResponse()
        self.assertIsNone(binary_response.file_name)
        binary_response.file_name = file_name_b
        self.assertEqual(binary_response.file_name, file_name_b)

    def test_as_attachment(self):
        binary_response = BinaryResponse()
        self.assertTrue(binary_response.as_attachment)

        binary_response.as_attachment = False
        self.assertFalse(binary_response.as_attachment)

    def test_contents(self):
        binary_response = BinaryResponse()
        self.assertIsNone(binary_response.contents)

        contents = "contents of binary response"
        binary_response.contents = contents
        self.assertEqual(binary_response.contents, contents)

    def test_content_length(self):

        binary_response = BinaryResponse()