Example #1
0
 def test_empty_path(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('')
         self.fail('Empty path should not be accepted')
     except ValueError:
         pass
Example #2
0
 def test_empty_content(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('../../resource/emptyFile.csv')
         self.fail('Invalid dataset should not be accepted')
     except InvalidFileContentError:
         pass
Example #3
0
 def test_invalid_file_extension(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('./random/dataset.txt')
         self.fail('Invalid file extension should not be accepted')
     except ValueError:
         pass
Example #4
0
 def test_invalid_path(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('./random/dataset.csv')
         self.fail('Invalid path should not be accepted')
     except ValueError:
         pass
Example #5
0
    def test_file_content(self):
        try:
            writer = CSVDatasetWriter()
            reader = CSVDatasetReader()
            generator = BaseDatasetGenerator()
            dataset = generator.make('test123', 30, 5, 5)
            writer.write('../../resource/', 'test_file_content', dataset)
            new_dataset = reader.read('../../resource/test_file_content.csv')
            is_valid = True

            if dataset.title != new_dataset.title:
                is_valid = False

            if dataset.total_packages != new_dataset.total_packages:
                is_valid = False

            if dataset.total_stations != new_dataset.total_stations:
                is_valid = False

            if dataset.width != new_dataset.width or dataset.height != new_dataset.height:
                is_valid = False

            if len(dataset.packages) != len(new_dataset.packages):
                is_valid = False

            self.assertEqual(True, is_valid)

        except ValueError as e:
            self.fail(e)
        finally:
            delete_if_exists('../../resource/test_file_content.csv')
Example #6
0
    def test_valid_content(self):
        try:
            reader = CSVDatasetReader()
            dataset = reader.read('../../resource/testSet.csv')

            self.assertEqual('TestSet1', dataset.title)
            self.assertEqual(120, dataset.total_packages)
            self.assertEqual(6, dataset.total_stations)
            self.assertEqual(15, dataset.width)
            self.assertEqual(15, dataset.height)

        except Exception as e:
            self.fail(e)
Example #7
0
 def test_valid_file_extension(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('../../resource/testSet.csv')
     except ValueError:
         self.fail('Valid file extension should be accepted')
Example #8
0
 def test_valid_path(self):
     try:
         reader = CSVDatasetReader()
         _ = reader.read('../../resource/testSet.csv')
     except ValueError:
         self.fail('Valid path should be accepted')