from unittest import TestCase

from dacsspace.dacsspace import DACSspace


class TestDACSspace(TestCase):

    def test_csv_filepath(self):
        """Asserts that CSV filepath is handled as expected.

        Filepaths are checked to ensure they end with the appropriate file
        extension (.csv) and don't contain any illegal characters.
        """
        DACSspace("csv_filepath.csv")
        with self.assertRaises(ValueError) as err:
            DACSspace("my*file.csv")
        self.assertEqual(str(err.exception),
                         'File name cannot contain the following characters: * ? : " < > | ')
        with self.assertRaises(ValueError) as err:
            DACSspace("myfile")
        self.assertEqual(str(err.exception),
                         "File must have .csv extension")

@@ -22,16 +22,48 @@
 TestCase
+%0Afrom unittest.mock import patch
 %0A%0Afrom d
@@ -832,8 +832,1562 @@
 nsion%22)%0A
+%0A    @patch('dacsspace.client.ArchivesSpaceClient.__init__')%0A    @patch('dacsspace.client.ArchivesSpaceClient.get_resources')%0A    @patch('dacsspace.validator.Validator.__init__')%0A    @patch('dacsspace.reporter.CSVReporter.__init__')%0A    @patch('dacsspace.reporter.CSVReporter.write_report')%0A    def test_args(self, mock_write_report, mock_reporter_init,%0A                  mock_validator_init, mock_get_resources, mock_client_init):%0A        %22%22%22Asserts that arguments are passed to the correct methods.%22%22%22%0A        mock_reporter_init.return_value = None%0A        mock_validator_init.return_value = None%0A        mock_client_init.return_value = None%0A        mock_get_resources.return_value = %5B%5D%0A        for csv_filepath, published_only, invalid_only, schema_identifier, schema_filepath in %5B%0A                ('myfile.csv', False, True, 'single_level_required.json', None),%0A                ('test.csv', True, True, None, 'filepath/to/schema.json'),%0A                ('testfile.csv', False, False, 'single_level_required', None),%0A                ('file.csv', True, False, 'rac.json', None)%5D:%0A            DACSspace(csv_filepath).run(%0A                published_only,%0A                invalid_only,%0A                schema_identifier,%0A                schema_filepath)%0A            mock_validator_init.assert_called_with(%0A                schema_identifier, schema_filepath)%0A            mock_reporter_init.assert_called_with(csv_filepath)%0A            mock_get_resources.assert_called_with(published_only)%0A            mock_write_report.assert_called_with(%5B%5D, invalid_only)%0A

add additional tests