# Path: auxi/core/reporting.py
# class ReportFormat(Enum):
#     """
#     Represents the format the report should be outputted as.
#     """
# 
#     printout = 1,
#     latex = 2,
#     txt = 3,
#     csv = 4,
#     string = 5,
#     matplotlib = 6,
#     png = 7
# 
# class Report(Object):
#     """
#     Base class for all auxi reports.
#     """
# 
#     def __init__(self, data_source, output_path=None):
#         self.data_source = data_source
#         self.output_path = output_path
# 
#     def _generate_table_(self):
#         return []
# 
#     def _render_matplotlib_(self, png=False):
#         pass
# 
#     def render(self, format=ReportFormat.printout):
#         """
#         Render the report in the specified format
# 
#         :param format: The format. The default format is to print
#           the report to the console.
# 
#         :returns: If the format was set to 'string' then a string
#           representation of the report is returned.
#         """
# 
#         table = self._generate_table_()
#         if format == ReportFormat.printout:
#             print(tabulate(table, headers="firstrow", tablefmt="simple"))
#         elif format == ReportFormat.latex:
#             self._render_latex_(table)
#         elif format == ReportFormat.txt:
#             self._render_txt_(table)
#         elif format == ReportFormat.csv:
#             self._render_csv_(table)
#         elif format == ReportFormat.string:
#             return str(tabulate(table, headers="firstrow", tablefmt="simple"))
#         elif format == ReportFormat.matplotlib:
#             self._render_matplotlib_()
#         elif format == ReportFormat.png:
#             if self.output_path is None:
#                 self._render_matplotlib_()
#             else:
#                 self._render_matplotlib_(True)
# 
#     def _render_latex_(self, table):
#         if self.output_path is not None:
#             with open(self.output_path + '.tex', 'w') as f:
#                 f.write(
#                     tabulate(table, headers="firstrow", tablefmt="latex"))
#         else:
#             print(tabulate(table, headers="firstrow", tablefmt="latex"))
# 
#     def _render_txt_(self, table):
#         if self.output_path is not None:
#             with open(self.output_path + '.txt', 'w') as f:
#                 f.write(
#                     tabulate(table, headers="firstrow", tablefmt="simple"))
#         else:
#             print(tabulate(table, headers="firstrow", tablefmt="simple"))
# 
#     def _render_csv_(self, table):
#         if self.output_path is not None:
#             with open(self.output_path + '.csv', 'w') as f:
#                 csv.writer(f, lineterminator='\n').writerows(table)
#         else:
#             with StringIO() as f:
#                 csv.writer(f, lineterminator='\n').writerows(table)
#                 print(f.getvalue())


import unittest
import os.path
from auxi.core.reporting import ReportFormat, Report


class ReportingUnitTester(unittest.TestCase):
    """
    The unit tester for the class being tested.
    """

    def setUp(self):
        self.object = Report([["cola", "colb"], [1, 2]])
        self.object_w_file = Report([["cola", "colb"], [1, 2]], "./test")

    def tearDown(self):
        del self.object

    def test_render_without_file(self):
        """
        Test whether a value is returned when a report is rendered in a
        string format. And whether any of the other formats throw an error.
        """

        self.object.render(format=ReportFormat.printout)
        self.object.render(format=ReportFormat.latex)
        self.object.render(format=ReportFormat.txt)
        self.object.render(format=ReportFormat.csv)

        self.assertEqual(
            len(self.object.render(format=ReportFormat.string)) > 0,
            True)

        self.object.render(format=ReportFormat.matplotlib)

# Path: auxi/core/reporting.py
# class ReportFormat(Enum):
#     """
#     Represents the format the report should be outputted as.
#     """
# 
#     printout = 1,
#     latex = 2,
#     txt = 3,
#     csv = 4,
#     string = 5,
#     matplotlib = 6,
#     png = 7
# 
# class Report(Object):
#     """
#     Base class for all auxi reports.
#     """
# 
#     def __init__(self, data_source, output_path=None):
#         self.data_source = data_source
#         self.output_path = output_path
# 
#     def _generate_table_(self):
#         return []
# 
#     def _render_matplotlib_(self, png=False):
#         pass
# 
#     def render(self, format=ReportFormat.printout):
#         """
#         Render the report in the specified format
# 
#         :param format: The format. The default format is to print
#           the report to the console.
# 
#         :returns: If the format was set to 'string' then a string
#           representation of the report is returned.
#         """
# 
#         table = self._generate_table_()
#         if format == ReportFormat.printout:
#             print(tabulate(table, headers="firstrow", tablefmt="simple"))
#         elif format == ReportFormat.latex:
#             self._render_latex_(table)
#         elif format == ReportFormat.txt:
#             self._render_txt_(table)
#         elif format == ReportFormat.csv:
#             self._render_csv_(table)
#         elif format == ReportFormat.string:
#             return str(tabulate(table, headers="firstrow", tablefmt="simple"))
#         elif format == ReportFormat.matplotlib:
#             self._render_matplotlib_()
#         elif format == ReportFormat.png:
#             if self.output_path is None:
#                 self._render_matplotlib_()
#             else:
#                 self._render_matplotlib_(True)
# 
#     def _render_latex_(self, table):
#         if self.output_path is not None:
#             with open(self.output_path + '.tex', 'w') as f:
#                 f.write(
#                     tabulate(table, headers="firstrow", tablefmt="latex"))
#         else:
#             print(tabulate(table, headers="firstrow", tablefmt="latex"))
# 
#     def _render_txt_(self, table):
#         if self.output_path is not None:
#             with open(self.output_path + '.txt', 'w') as f:
#                 f.write(
#                     tabulate(table, headers="firstrow", tablefmt="simple"))
#         else:
#             print(tabulate(table, headers="firstrow", tablefmt="simple"))
# 
#     def _render_csv_(self, table):
#         if self.output_path is not None:
#             with open(self.output_path + '.csv', 'w') as f:
#                 csv.writer(f, lineterminator='\n').writerows(table)
#         else:
#             with StringIO() as f:
#                 csv.writer(f, lineterminator='\n').writerows(table)
#                 print(f.getvalue())


# Path: auxi/core/reporting_test.py
import unittest
import os.path
from auxi.core.reporting import ReportFormat, Report



class ReportingUnitTester(unittest.TestCase):
    """
    The unit tester for the class being tested.
    """

    def setUp(self):
        self.object = Report([["cola", "colb"], [1, 2]])
        self.object_w_file = Report([["cola", "colb"], [1, 2]], "./test")

    def tearDown(self):
        del self.object

    def test_render_without_file(self):
        """
        Test whether a value is returned when a report is rendered in a
        string format. And whether any of the other formats throw an error.
        """

        self.object.render(format=ReportFormat.printout)
        self.object.render(format=ReportFormat.latex)
        self.object.render(format=ReportFormat.txt)
        self.object.render(format=ReportFormat.csv)

        self.assertEqual(
            len(self.object.render(format=ReportFormat.string)) > 0,
            True)

        self.object.render(format=ReportFormat.matplotlib)

        self.object.render(format=ReportFormat.png)