# Path: mfr/core/exceptions.py
# class RendererError(ExtensionError):
#     """The MFR related errors raised from a :class:`mfr.core.extension` and relating to rendering
#     should inherit from RendererError
#     """
# 
#     __TYPE = 'renderer'
# 
#     def __init__(self, message, *args, renderer_class: str='', **kwargs):
#         super().__init__(message, *args, **kwargs)
#         self.renderer_class = renderer_class
#         self.attr_stack.append([self.__TYPE, {'class': self.renderer_class}])
# 
# Path: mfr/core/provider.py
# class ProviderMetadata:
# 
#     def __init__(self, name, ext, content_type, unique_key, download_url, stable_id=None):
#         self.name = name
#         self.ext = ext
#         self.content_type = content_type
#         self.unique_key = unique_key
#         self.download_url = download_url
#         self.stable_id = stable_id
# 
#     def serialize(self):
#         return {
#             'name': self.name,
#             'ext': self.ext,
#             'content_type': self.content_type,
#             'unique_key': str(self.unique_key),
#             'download_url': str(self.download_url),
#             'stable_id': None if self.stable_id is None else str(self.stable_id),
#         }
# 
# Path: mfr/extensions/codepygments/settings.py
# MAX_SIZE = int(config.get('MAX_SIZE', 204800))  # 200kb
# 
# Path: mfr/extensions/codepygments/exceptions.py
# class FileTooLargeError(CodePygmentsRendererError):
#     """The codepygments related errors raised from a :class:`mfr.extentions.codepygments` and
#     relating to limit on size of file to display should inherit from FileTooLargeError
#     """
# 
#     __TYPE = 'codepygments_file_too_large'
# 
#     def __init__(self, message, *args, code: int=400, file_size: int=None, max_size: int=None,
#                  **kwargs):
#         super().__init__(message, *args, code=code, **kwargs)
# 
#         self.file_size = file_size
#         self.max_size = max_size
# 
#         self.attr_stack.append([self.__TYPE, {
#             'file_size': self.file_size,
#             'max_size': self.max_size
#         }])


import os
import pytest
from tempfile import NamedTemporaryFile
from mfr.core.exceptions import RendererError
from mfr.core.provider import ProviderMetadata
from mfr.extensions.codepygments import settings, CodePygmentsRenderer
from mfr.extensions.codepygments.exceptions import FileTooLargeError




@pytest.fixture
def metadata():
    return ProviderMetadata('test', '.xml', 'text/plain', '1234', 'http://wb.osf.io/file/good.xml?token=1234')


@pytest.fixture
def test_file_path():
        return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files', 'test.xml')

@pytest.fixture
def max_size_file_path():
    dir_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'files')
    with NamedTemporaryFile(mode='w+b', suffix='.txt', dir=dir_path,
                            delete=False) as temp_file:
        temp_file_path = temp_file.name

# Path: mfr/core/exceptions.py
# class RendererError(ExtensionError):
#     """The MFR related errors raised from a :class:`mfr.core.extension` and relating to rendering
#     should inherit from RendererError
#     """
# 
#     __TYPE = 'renderer'
# 
#     def __init__(self, message, *args, renderer_class: str='', **kwargs):
#         super().__init__(message, *args, **kwargs)
#         self.renderer_class = renderer_class
#         self.attr_stack.append([self.__TYPE, {'class': self.renderer_class}])
# 
# Path: mfr/core/provider.py
# class ProviderMetadata:
# 
#     def __init__(self, name, ext, content_type, unique_key, download_url, stable_id=None):
#         self.name = name
#         self.ext = ext
#         self.content_type = content_type
#         self.unique_key = unique_key
#         self.download_url = download_url
#         self.stable_id = stable_id
# 
#     def serialize(self):
#         return {
#             'name': self.name,
#             'ext': self.ext,
#             'content_type': self.content_type,
#             'unique_key': str(self.unique_key),
#             'download_url': str(self.download_url),
#             'stable_id': None if self.stable_id is None else str(self.stable_id),
#         }
# 
# Path: mfr/extensions/codepygments/settings.py
# MAX_SIZE = int(config.get('MAX_SIZE', 204800))  # 200kb
# 
# Path: mfr/extensions/codepygments/exceptions.py
# class FileTooLargeError(CodePygmentsRendererError):
#     """The codepygments related errors raised from a :class:`mfr.extentions.codepygments` and
#     relating to limit on size of file to display should inherit from FileTooLargeError
#     """
# 
#     __TYPE = 'codepygments_file_too_large'
# 
#     def __init__(self, message, *args, code: int=400, file_size: int=None, max_size: int=None,
#                  **kwargs):
#         super().__init__(message, *args, code=code, **kwargs)
# 
#         self.file_size = file_size
#         self.max_size = max_size
# 
#         self.attr_stack.append([self.__TYPE, {
#             'file_size': self.file_size,
#             'max_size': self.max_size
#         }])


# Path: tests/extensions/codepygments/test_renderer.py
import os
import pytest
from tempfile import NamedTemporaryFile
from mfr.core.exceptions import RendererError
from mfr.core.provider import ProviderMetadata
from mfr.extensions.codepygments import settings, CodePygmentsRenderer
from mfr.extensions.codepygments.exceptions import FileTooLargeError





@pytest.fixture
def metadata():
    return ProviderMetadata('test', '.xml', 'text/plain', '1234', 'http://wb.osf.io/file/good.xml?token=1234')


@pytest.fixture
def test_file_path():
        return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files', 'test.xml')

@pytest.fixture
def max_size_file_path():
    dir_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            'files')
    with NamedTemporaryFile(mode='w+b', suffix='.txt', dir=dir_path,
                            delete=False) as temp_file:
        temp_file_path = temp_file.name

        file_size = settings.MAX_SIZE