def test_hash_csv_with_valid_input(self): self.config.COLUMNS_TO_HASH = ['SSN'] mock_keys = { ApiKeys.SALT_KEYS: [{ "value": "test-salt-key" }], ApiKeys.ENCRYPTION_KEY: "_hSmVyMTLi-Qo_rmISp8jrH5Aob7frHp1X-28sxQZAU=" } file_data = HashService.read_csv(self.config.FILES[0], self.config) HashService.hash_csv(self.config.FILES[0], file_data, self.config, mock_keys)
def test_write_hashed_csv_with_valid_input(self): file_data = HashService.read_csv(self.config.FILES[0], self.config) mock_keys = { ApiKeys.SALT_KEYS: [{ "value": "test-salt-key" }], ApiKeys.ENCRYPTION_KEY: "_hSmVyMTLi-Qo_rmISp8jrH5Aob7frHp1X-28sxQZAU=" } HashService.hash_csv(self.config.FILES[0], file_data, self.config, mock_keys) HashService.write_hashed_csv(self.config.FILES[0], file_data, self.config) assert os.path.exists(self.config.HASHED_FILES[0]) os.remove(self.config.HASHED_FILES[0])
def test_verify_columns_to_hash_exist_with_invalid_column(self): with pytest.raises(ValueError): self.config.COLUMNS_TO_HASH = ["Bad-Column"] file_data = HashService.read_csv(self.config.FILES[0], self.config) HashService.verify_columns_to_hash_exist(self.config.FILES[0], file_data, self.config)
def test_verify_columns_to_hash_exist_with_valid_column(self): self.config.CSV_DELIMITER = ',' file_data = HashService.read_csv(self.config.FILES[0], self.config) HashService.verify_columns_to_hash_exist(self.config.FILES[0], file_data, self.config)
def test_read_csv_with_empty_csv_delimiter(self): with pytest.raises(TypeError): self.config.FILES = ['example_inois_data.csv'] self.config.CSV_DELIMITER = '' HashService.read_csv(self.config.FILES[0], self.config)
def test_read_csv_with_non_csv_file(self): with pytest.raises(TypeError): self.config.FILES = ['png_image_file.csv'] HashService.read_csv(self.config.FILES[0], self.config)
def test_read_csv_with_empty_csv_file(self): with pytest.raises(ValueError): self.config.FILES = ['empty_file.csv'] HashService.read_csv(self.config.FILES[0], self.config)
def test_read_csv_with_valid_csv_file(self): HashService.read_csv(self.config.FILES[0], self.config)