def setUp(self): super(CLITestHelper, self).setUp() self.pii_file = create_temp_file() self.pii_file_2 = create_temp_file() # Get random PII pii_data = randomnames.NameList(self.SAMPLES) data = [(name, dob) for _, name, dob, _ in pii_data.names] headers = ['NAME freetext', 'DOB YYYY/MM/DD'] randomnames.save_csv(data, headers, self.pii_file) random.shuffle(data) randomnames.save_csv(data[::2], headers, self.pii_file_2) self.default_schema = [{ "identifier": "INDEX" }, { "identifier": "NAME freetext" }, { "identifier": "DOB YYYY/MM/DD" }, { "identifier": "GENDER M or F" }] self.pii_file.close() self.pii_file_2.close()
def setUp(self): self.pii_file = create_temp_file() pii_data = randomnames.NameList(TestHasherDefaultSchema.samples) randomnames.save_csv(pii_data.names, [f.identifier for f in pii_data.SCHEMA.fields], self.pii_file) self.pii_file.flush()
def setUp(self): super(TestCliInteractionWithService, self).setUp() self.url = os.environ['TEST_ENTITY_SERVICE'] self.clk_file = create_temp_file() self.clk_file_2 = create_temp_file() # hash some PII for uploading runner = CliRunner() cli_result = runner.invoke(clkhash.cli.cli, [ 'hash', self.pii_file.name, 'secretkey1', 'secretkey2', SIMPLE_SCHEMA_PATH, self.clk_file.name ]) assert cli_result.exit_code == 0 cli_result = runner.invoke(clkhash.cli.cli, [ 'hash', self.pii_file_2.name, 'secretkey1', 'secretkey2', SIMPLE_SCHEMA_PATH, self.clk_file_2.name ]) assert cli_result.exit_code == 0 self.clk_file.close() self.clk_file_2.close()
def test_hashing_json_schema(self): runner = CliRunner() pii_data = randomnames.NameList(self.SAMPLES) pii_file = create_temp_file() randomnames.save_csv(pii_data.names, [f.identifier for f in pii_data.SCHEMA.fields], pii_file) pii_file.close() with temporary_file() as output_filename: with open(output_filename) as output: cli_result = runner.invoke(clkhash.cli.cli, [ 'hash', pii_file.name, 'secretkey1', 'secretkey2', RANDOMNAMES_SCHEMA_PATH, output.name ]) self.assertEqual(cli_result.exit_code, 0, msg=cli_result.output) with open(output_filename) as output: self.assertIn('clks', json.load(output))