# Path: ddsc/core/consistency.py
# class UploadDetails(object):
# class ProjectChecker(object):
#     def __init__(self, dds_file, remote_path):
#     def inconsistent(self):
#     def had_error(self):
#     def is_bad(self):
#     def name(self):
#     def status_str(self):
#     def file_id(self):
#     def message(self):
#     def __init__(self, config, project):
#     def files_are_ok(self):
#     def _try_fetch_project_files(self):
#     def get_bad_uploads(self):
#     def get_bad_uploads_table_data(self):
#     def delete_bad_uploads(self):
#     def print_bad_uploads_table(self):
#     def wait_for_consistency(self, wait_sec=5):
# 
# Path: ddsc/core/ddsapi.py
# class DataServiceError(Exception):
#     """
#     Error that wraps up info about it and creates an informative string.
#     """
#     def __init__(self, response, url_suffix, request_data):
#         """
#         Create exception for failed response.
#         :param response: requests.Response response that was in error
#         :param url_suffix: str url we were trying to connect to
#         :param request_data: object data we were sending to url
#         """
#         resp_json = None
#         try:
#             resp_json = response.json()
#         except:
#             resp_json = {}
#         if response.status_code == 500:
#             if resp_json and not resp_json.get('reason'):
#                 resp_json = {'reason': 'Internal Server Error', 'suggestion': 'Contact DDS support.'}
#         Exception.__init__(self, 'Error {} on {}\nReason:{}\nSuggestion:{}'.format(
#             response.status_code, url_suffix, resp_json.get('reason', resp_json.get('error', '')),
#             resp_json.get('suggestion', '')
#         ))
#         self.response = resp_json
#         self.url_suffix = url_suffix
#         self.request_data = request_data
#         self.status_code = response.status_code


from unittest import TestCase
from ddsc.core.consistency import UploadDetails, ProjectChecker, DSResourceNotConsistentError
from ddsc.core.ddsapi import DataServiceError
from mock import Mock, patch, call
        upload_details = UploadDetails(mock_dds_file, '/data/file1.dat')
        self.assertEqual(upload_details.inconsistent(), True)
        self.assertEqual(upload_details.had_error(), False)
        self.assertEqual(upload_details.is_bad(), True)
        self.assertEqual(upload_details.name(), 'file1.dat')
        self.assertEqual(upload_details.status_str(), 'Inconsistent')
        self.assertEqual(upload_details.file_id(), '123')
        self.assertEqual(upload_details.message(), 'started upload at 2021-01-01')

    def test_error_status(self):
        mock_dds_file = Mock()
        mock_dds_file.name = 'file1.dat'
        mock_dds_file.id = '123'
        mock_status = Mock(is_consistent=True, initiated_on='2021-01-01', error_on='2021-01-02', error_message='bad data')
        mock_dds_file.get_upload.return_value.status = mock_status
        upload_details = UploadDetails(mock_dds_file, '/data/file1.dat')
        self.assertEqual(upload_details.inconsistent(), False)
        self.assertEqual(upload_details.had_error(), True)
        self.assertEqual(upload_details.is_bad(), True)
        self.assertEqual(upload_details.name(), 'file1.dat')
        self.assertEqual(upload_details.status_str(), 'Error')
        self.assertEqual(upload_details.file_id(), '123')
        self.assertEqual(upload_details.message(), 'bad data')

    def test_error_ok(self):
        mock_dds_file = Mock()
        mock_dds_file.name = 'file1.dat'
        mock_dds_file.id = '123'
        mock_status = Mock(is_consistent=True, initiated_on='2021-01-01', error_on=None, error_message=None)
        mock_dds_file.get_upload.return_value.status = mock_status

# Path: ddsc/core/consistency.py
# class UploadDetails(object):
# class ProjectChecker(object):
#     def __init__(self, dds_file, remote_path):
#     def inconsistent(self):
#     def had_error(self):
#     def is_bad(self):
#     def name(self):
#     def status_str(self):
#     def file_id(self):
#     def message(self):
#     def __init__(self, config, project):
#     def files_are_ok(self):
#     def _try_fetch_project_files(self):
#     def get_bad_uploads(self):
#     def get_bad_uploads_table_data(self):
#     def delete_bad_uploads(self):
#     def print_bad_uploads_table(self):
#     def wait_for_consistency(self, wait_sec=5):
# 
# Path: ddsc/core/ddsapi.py
# class DataServiceError(Exception):
#     """
#     Error that wraps up info about it and creates an informative string.
#     """
#     def __init__(self, response, url_suffix, request_data):
#         """
#         Create exception for failed response.
#         :param response: requests.Response response that was in error
#         :param url_suffix: str url we were trying to connect to
#         :param request_data: object data we were sending to url
#         """
#         resp_json = None
#         try:
#             resp_json = response.json()
#         except:
#             resp_json = {}
#         if response.status_code == 500:
#             if resp_json and not resp_json.get('reason'):
#                 resp_json = {'reason': 'Internal Server Error', 'suggestion': 'Contact DDS support.'}
#         Exception.__init__(self, 'Error {} on {}\nReason:{}\nSuggestion:{}'.format(
#             response.status_code, url_suffix, resp_json.get('reason', resp_json.get('error', '')),
#             resp_json.get('suggestion', '')
#         ))
#         self.response = resp_json
#         self.url_suffix = url_suffix
#         self.request_data = request_data
#         self.status_code = response.status_code


# Path: ddsc/core/tests/test_consistency.py
from unittest import TestCase
from ddsc.core.consistency import UploadDetails, ProjectChecker, DSResourceNotConsistentError
from ddsc.core.ddsapi import DataServiceError
from mock import Mock, patch, call

        upload_details = UploadDetails(mock_dds_file, '/data/file1.dat')
        self.assertEqual(upload_details.inconsistent(), True)
        self.assertEqual(upload_details.had_error(), False)
        self.assertEqual(upload_details.is_bad(), True)
        self.assertEqual(upload_details.name(), 'file1.dat')
        self.assertEqual(upload_details.status_str(), 'Inconsistent')
        self.assertEqual(upload_details.file_id(), '123')
        self.assertEqual(upload_details.message(), 'started upload at 2021-01-01')

    def test_error_status(self):
        mock_dds_file = Mock()
        mock_dds_file.name = 'file1.dat'
        mock_dds_file.id = '123'
        mock_status = Mock(is_consistent=True, initiated_on='2021-01-01', error_on='2021-01-02', error_message='bad data')
        mock_dds_file.get_upload.return_value.status = mock_status
        upload_details = UploadDetails(mock_dds_file, '/data/file1.dat')
        self.assertEqual(upload_details.inconsistent(), False)
        self.assertEqual(upload_details.had_error(), True)
        self.assertEqual(upload_details.is_bad(), True)
        self.assertEqual(upload_details.name(), 'file1.dat')
        self.assertEqual(upload_details.status_str(), 'Error')
        self.assertEqual(upload_details.file_id(), '123')
        self.assertEqual(upload_details.message(), 'bad data')

    def test_error_ok(self):
        mock_dds_file = Mock()
        mock_dds_file.name = 'file1.dat'
        mock_dds_file.id = '123'
        mock_status = Mock(is_consistent=True, initiated_on='2021-01-01', error_on=None, error_message=None)
        mock_dds_file.get_upload.return_value.status = mock_status

        upload_details = UploadDetails(mock_dds_file, '/data/file1.dat')