Exemplo n.º 1
0
 def test_dryrunhandler_no_dataset_size(self, invalid_no_size_dataset):
     with open('invalid_spec.json', 'w') as f:
         json.dump(invalid_no_size_dataset, f)
     with pytest.raises(ValueError):
         handler = DryRunHandler({'config_file': 'invalid_spec.json'})
         handler.valid_specification_dryrun()
     remove('invalid_spec.json')
Exemplo n.º 2
0
 def test_dryrunhandler_valid(self, valid_specification):
     with open('valid_spec.json', 'w') as f:
         json.dump(valid_specification, f)
     handler = DryRunHandler({'config_file': 'valid_spec.json'})
     config = handler.valid_specification_dryrun()
     assert valid_specification == config
     remove('valid_spec.json')
Exemplo n.º 3
0
    def test_generate_dryrun(self, mocker, valid_specification):
        mock_config = mocker.patch \
                            .object(DryRunHandler,
                                    'valid_specification_dryrun')
        mock_config.return_value = valid_specification

        handler = DryRunHandler(arguments={'config_file': None})
        assert handler.generate() is None
Exemplo n.º 4
0
 def test_output(self, valid_dryrun, valid_specification):
     with open('valid_spec.json', 'w') as f:
         json.dump(valid_specification, f)
     handler = BaseHandler()
     dry = DryRunHandler({'config_file': 'valid_spec.json'})
     dataframe = handler.generate_dataframe(valid_dryrun, 10)
     key = "sample"
     dataset_fields = valid_dryrun['fields']
     assert dry.print_dryrun(dataframe, key, dataset_fields) is None
     remove('valid_spec.json')
Exemplo n.º 5
0
    def test_float_dataframe(self, mocker, float_specification):
        mock = mocker.patch \
                     .object(DryRunHandler, 'valid_specification_dryrun')
        mock.return_value = float_specification
        handler = DryRunHandler({'config_file': None})
        specification = handler.valid_specification_dryrun()
        dataframe = handler.generate_dryrun(specification)

        assert isinstance(dataframe, DataFrame) is True
        assert dataframe.shape[0] == 10
        for field in float_specification['fields']:
            assert dataframe[field['name']].dtype.name == field['expected']
Exemplo n.º 6
0
    def test_bool_dataframe(self, mocker, bool_specification):
        with patch('builtins.open',
                   mock_open(read_data=json.dumps(bool_specification))):
            dataset = bool_specification['datasets']['sample']
            expected_size = 10
            expected_fields = dataset['fields']

            handler = DryRunHandler({"config_file": None})
            dataframe = handler.generate_dryrun(dataset)

            assert isinstance(dataframe, DataFrame) is True
            assert dataframe.shape[0] == expected_size
            for field in expected_fields:
                assert dataframe[field['name']].dtype.name == field['expected']
Exemplo n.º 7
0
def generate_dryrun(spec_path):
    try:
        dryrun = DryRunHandler(arguments={'config_file': spec_path})
        dryrun.generate()
    except Exception as err:
        click.echo(f"Error: {err}")