# Path: elodie/constants.py

# 
# Path: elodie/result.py
# class Result(object):
# 
#     def __init__(self):
#         self.records = []
#         self.success = 0
#         self.error = 0
#         self.error_items = []
# 
#     def append(self, row):
#         id, status = row
# 
#         if status:
#             self.success += 1
#         else:
#             self.error += 1
#             self.error_items.append(id)
# 
#     def write(self):
#         if self.error > 0:
#             error_headers = ["File"]
#             error_result = []
#             for id in self.error_items:
#                 error_result.append([id])
# 
#             print("****** ERROR DETAILS ******")
#             print(tabulate(error_result, headers=error_headers))
#             print("\n")
# 
#         headers = ["Metric", "Count"]
#         result = [
#                     ["Success", self.success],
#                     ["Error", self.error],
#                  ]
# 
#         print("****** SUMMARY ******")
#         print(tabulate(result, headers=headers))


import os
import sys
import unittest 
from json import dumps
from mock import patch
    from StringIO import StringIO
    from io import StringIO
from elodie import constants
from elodie.result import Result
from __future__ import absolute_import
# Project imports


try:
except ImportError:

sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))


def call_result_and_assert(result, expected):
    saved_stdout = sys.stdout
    try:
        out = StringIO()
        sys.stdout = out
        result.write()
        output = out.getvalue().strip()
        assert output == expected, output
    finally:
        sys.stdout = saved_stdout

def test_add_multiple_rows_with_success():
    expected = """****** SUMMARY ******
Metric      Count
--------  -------
Success         2
Error           0"""

# Path: elodie/constants.py

# 
# Path: elodie/result.py
# class Result(object):
# 
#     def __init__(self):
#         self.records = []
#         self.success = 0
#         self.error = 0
#         self.error_items = []
# 
#     def append(self, row):
#         id, status = row
# 
#         if status:
#             self.success += 1
#         else:
#             self.error += 1
#             self.error_items.append(id)
# 
#     def write(self):
#         if self.error > 0:
#             error_headers = ["File"]
#             error_result = []
#             for id in self.error_items:
#                 error_result.append([id])
# 
#             print("****** ERROR DETAILS ******")
#             print(tabulate(error_result, headers=error_headers))
#             print("\n")
# 
#         headers = ["Metric", "Count"]
#         result = [
#                     ["Success", self.success],
#                     ["Error", self.error],
#                  ]
# 
#         print("****** SUMMARY ******")
#         print(tabulate(result, headers=headers))


# Path: elodie/tests/result_test.py
import os
import sys
import unittest 
from json import dumps
from mock import patch
    from StringIO import StringIO
    from io import StringIO
from elodie import constants
from elodie.result import Result

from __future__ import absolute_import
# Project imports


try:
except ImportError:

sys.path.insert(0, os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))))


def call_result_and_assert(result, expected):
    saved_stdout = sys.stdout
    try:
        out = StringIO()
        sys.stdout = out
        result.write()
        output = out.getvalue().strip()
        assert output == expected, output
    finally:
        sys.stdout = saved_stdout

def test_add_multiple_rows_with_success():
    expected = """****** SUMMARY ******
Metric      Count
--------  -------
Success         2
Error           0"""

    result = Result()