def test_valid_package_number(self):
     generator = BaseDatasetGenerator()
     try:
         dataset = generator.make('test123', 30, 5, 5)
         self.assertEqual('test123', dataset.title)
     except ValueError as e:
         self.fail(e)
 def test_to_small_cargo_space(self):
     generator = BaseDatasetGenerator()
     try:
         _ = generator.make('', 100, 5, 5)
         self.fail()
     except ValueError:
         pass
 def test_none_title(self):
     generator = BaseDatasetGenerator()
     try:
         _ = generator.make(None, 30, 5, 5)
         self.fail()
     except ValueError:
         pass
 def test_invalid_package_number(self):
     generator = BaseDatasetGenerator()
     try:
         _ = generator.make('test123', 7, 5, 2)
         self.fail()
     except ValueError:
         pass
Ejemplo n.º 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')
 def test_invalid_dimension_number(self):
     generator = BaseDatasetGenerator()
     try:
         _ = generator.make('test123', 30, 5, 2)
         self.fail()
     except ValueError:
         pass
    def test_valid_in_out_station(self):
        generator = BaseDatasetGenerator()
        try:
            dataset = generator.make('test123', 54, 5, 5)

            for package in dataset.packages:
                if package.station_in >= package.station_out:
                    self.fail('Invalid package route attributes.')
        except ValueError as e:
            self.fail(e)
Ejemplo n.º 8
0
    def test_invalid_path(self):
        try:
            writer = CSVDatasetWriter()
            generator = BaseDatasetGenerator()
            writer.write('', 'test_empty_path_ds',
                         generator.make('test123', 30, 5, 5))
            self.fail('Empty path error was not thrown.')

        except ValueError:
            pass
Ejemplo n.º 9
0
    def test_invalid_filename(self):
        try:
            writer = CSVDatasetWriter()
            generator = BaseDatasetGenerator()
            writer.write('../../resource/', '',
                         generator.make('test123', 30, 5, 5))
            self.fail('Empty path error was not thrown.')

        except ValueError:
            pass
Ejemplo n.º 10
0
    def test_valid_path_filename(self):
        try:
            writer = CSVDatasetWriter()
            generator = BaseDatasetGenerator()
            writer.write('../../resource/', 'test_valid_path_filename',
                         generator.make('test123', 30, 5, 5))

        except ValueError as e:
            self.fail(e)
        finally:
            delete_if_exists('../../resource/test_valid_path_filename.csv')
Ejemplo n.º 11
0
def generate_data_set():
    try:
        generator = BaseDatasetGenerator()
        csv_writer = CSVDatasetWriter()
        new_ds = generator.make(title='testSet3',
                                pack_c=225,
                                stat_n=5,
                                cargo_dim=10)
        csv_writer.write(dir_path='../datasets',
                         file_name='testSet3',
                         dataset=new_ds)
    except Exception as error:
        print(str(error))
Ejemplo n.º 12
0
    def test_duplicate_file(self):
        try:
            writer = CSVDatasetWriter()
            generator = BaseDatasetGenerator()
            dataset = generator.make('test123', 30, 5, 5)
            writer.write('../../resource/', 'test_duplicate_file', dataset)
            writer.write('../../resource/', 'test_duplicate_file', dataset)
            self.fail('Duplicate file exception was not thrown')

        except ValueError:
            pass
        finally:
            delete_if_exists('../../resource/test_duplicate_file.csv')