diff --git a/tests/__init__.py b/tests/__init__.py index 3e1ec2f..d8c6917 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -7,14 +7,14 @@ def assert_results(testcase, results, expected_fail_count): for val in res.field_validations: if not val.valid: if not result_partition_printed: - print("\n========") + # print("\n========") result_partition_printed = True serial_id = res.serial_id if not serial_id: serial_id = val.serial_id - - print("SerialId: %s, Field: %s, Details: %s\n--------\n%s" % (serial_id , val.field_path, val.details, res.record)) + + # print("SerialId: %s, Field: %s, Details: %s\n--------\n%s" % (serial_id , val.field_path, val.details, res.record)) fail_count += 1 - testcase.assertEquals(expected_fail_count, fail_count, "Expected %s failures, got %s failures." % (expected_fail_count, fail_count)) + testcase.assertEqual(expected_fail_count, fail_count, "Expected %s failures, got %s failures." % (expected_fail_count, fail_count)) diff --git a/tests/result_test.py b/tests/result_test.py index f738e73..6cfe152 100644 --- a/tests/result_test.py +++ b/tests/result_test.py @@ -7,14 +7,14 @@ class ResultTest(unittest.TestCase): def testFieldValidationResult(self): f = FieldValidationResult() self.assertTrue(f.valid) - self.assertEquals("", f.details) - self.assertEquals(None, f.field_path) - self.assertEquals('{"Field": null, "Valid": true, "Details": "", "SerialId": null}', json.dumps(f.to_json())) - self.assertEquals('{"Field": null, "Valid": true, "Details": "", "SerialId": null}', str(f)) + self.assertEqual("", f.details) + self.assertEqual(None, f.field_path) + self.assertEqual('{"Field": null, "Valid": true, "Details": "", "SerialId": null}', json.dumps(f.to_json())) + self.assertEqual('{"Field": null, "Valid": true, "Details": "", "SerialId": null}', str(f)) def testRecordValidationResult(self): f = RecordValidationResult("serial_id", [FieldValidationResult()], "record") - self.assertEquals("serial_id", f.serial_id) - self.assertEquals("record", f.record) - self.assertEquals('{"SerialId": "serial_id", "Validations": [{"Field": null, "Valid": true, "Details": "", "SerialId": null}], "Record": "record"}', json.dumps(f.to_json())) - self.assertEquals('{"SerialId": "serial_id", "Validations": [{"Field": null, "Valid": true, "Details": "", "SerialId": null}], "Record": "record"}', str(f)) + self.assertEqual("serial_id", f.serial_id) + self.assertEqual("record", f.record) + self.assertEqual('{"SerialId": "serial_id", "Validations": [{"Field": null, "Valid": true, "Details": "", "SerialId": null}], "Record": "record"}', json.dumps(f.to_json())) + self.assertEqual('{"SerialId": "serial_id", "Validations": [{"Field": null, "Valid": true, "Details": "", "SerialId": null}], "Record": "record"}', str(f)) diff --git a/tests/sequential_test.py b/tests/sequential_test.py index bfd0d4d..c613940 100644 --- a/tests/sequential_test.py +++ b/tests/sequential_test.py @@ -17,13 +17,13 @@ def setUp(self): self.record_list = self.build_happy_path(self.json_seed) def test_happy_path(self): - print("Testing Happy Path ...") + # print("Testing Happy Path ...") record_list = self.build_happy_path(self.json_seed) results = self.seq.perform_sequential_validations(record_list) assert_results(self, results, 0) def test_missing_records(self): - print("Testing Missing recordId, serialNumber ...") + # print("Testing Missing recordId, serialNumber ...") self.record_list.remove(self.record_list[19]) self.record_list.remove(self.record_list[8]) self.record_list.remove(self.record_list[2]) @@ -31,16 +31,16 @@ def test_missing_records(self): assert_results(self, results, 7) def test_invalid_bundle_size(self): - print("Testing invalid bundleSize ...") + # print("Testing invalid bundleSize ...") self.record_list.remove(self.record_list[15]) self.record_list.remove(self.record_list[6]) results = self.seq.perform_sequential_validations(self.record_list) - # Even though we have removed the last record of a full bundle, the validator can't detect if this is a head of a full list or a full list. + # Even though we have removed the last record of a full bundle, the validator can't detect if this is a head of a full list or a full list. # Therefore, we should get only one validation error assert_results(self, results, 1) def test_dup_and_chronological(self): - print("Testing Duplicate recordId and serialNumber and non-chronological odeReceivedAt and recordGeneratedAt ...") + # print("Testing Duplicate recordId and serialNumber and non-chronological odeReceivedAt and recordGeneratedAt ...") self.record_list[18] = copy.deepcopy(self.record_list[16]) self.record_list[9] = copy.deepcopy(self.record_list[7]) self.record_list[2] = copy.deepcopy(self.record_list[0]) @@ -89,7 +89,7 @@ def _build_bundle(self, seed_record, count): bundle.append(cur_record) cur_record = self._next_record(cur_record) count -= 1 - + return bundle def _next_record(self, cur_record): @@ -101,4 +101,3 @@ def _next_record(self, cur_record): next_record['metadata']['odeReceivedAt'] = received_at.isoformat() next_record['metadata']['recordGeneratedAt'] = generated_at.isoformat() return next_record - diff --git a/tests/validator_field_test.py b/tests/validator_field_test.py index df02c74..55209ca 100644 --- a/tests/validator_field_test.py +++ b/tests/validator_field_test.py @@ -21,7 +21,7 @@ def test_constructor_fails_no_type(self): self.assertEqual("Missing required configuration property 'Type' for field a.b.c={}", str(e)) def test_constructor_fails_no_field_config(self): - self.assertEquals('{"Path": "a.b.c", "Type": null, "UpperLimit": null, "LowerLimit": null, "Values": null, "EqualsValue": null, "EarliestTime": null, "LatestTime": null, "AllowEmpty": null}', str(Field("a.b.c"))) + self.assertEqual('{"Path": "a.b.c", "Type": null, "UpperLimit": null, "LowerLimit": null, "Values": null, "EqualsValue": null, "EarliestTime": null, "LatestTime": null, "AllowEmpty": null}', str(Field("a.b.c"))) def test_constructor_fails_invalid_earliesttime(self): input_field_object = {"Type":"timestamp", "EarliestTime":"invalidtimestamp"} @@ -34,7 +34,7 @@ def test_constructor_fails_invalid_earliesttime(self): def test_constructor_succeeds_valid_earliesttime(self): input_field_object = {"Type":"timestamp", "EarliestTime":"2019-03-14T14:54:21.596Z"} actual_field = Field("a.b.c", input_field_object) - self.assertEqual("2019-03-14 14:54:21.596000+00:00", str(actual_field.earliest_time)) + self.assertEqual("2019-03-14 14:54:21+00:00", str(actual_field.earliest_time)) def test_constructor_fails_invalid_latesttime(self): input_field_object = {"Type":"timestamp", "LatestTime":"invalidtimestamp"} @@ -47,7 +47,7 @@ def test_constructor_fails_invalid_latesttime(self): def test_constructor_succeeds_valid_latesttime(self): input_field_object = {"Type":"timestamp", "LatestTime":"2019-03-14T14:54:21.596Z"} actual_field = Field("a.b.c", input_field_object) - self.assertEqual("2019-03-14 14:54:21.596000+00:00", str(actual_field.latest_time)) + self.assertEqual("2019-03-14 14:54:21+00:00", str(actual_field.latest_time)) def test_constructor_succeeds_latesttime_now_keyword(self): input_field_object = {"Type":"timestamp", "LatestTime":"NOW"} @@ -169,6 +169,5 @@ def test_validate_returns_success_timestamp_after_earliest_time(self): def testFieldSerialization(self): test_field_object = {"Type":"timestamp", "EarliestTime":"2019-03-14T14:54:20.000Z"} test_field = Field("a.b.c", test_field_object) - self.assertEquals('{"Path": "a.b.c", "Type": "timestamp", "UpperLimit": null, "LowerLimit": null, "Values": null, "EqualsValue": null, "EarliestTime": "2019-03-14T14:54:20+00:00", "LatestTime": null, "AllowEmpty": false}', json.dumps(test_field.to_json())) - self.assertEquals('{"Path": "a.b.c", "Type": "timestamp", "UpperLimit": null, "LowerLimit": null, "Values": null, "EqualsValue": null, "EarliestTime": "2019-03-14T14:54:20+00:00", "LatestTime": null, "AllowEmpty": false}', str(test_field)) - + self.assertEqual('{"Path": "a.b.c", "Type": "timestamp", "UpperLimit": null, "LowerLimit": null, "Values": null, "EqualsValue": null, "EarliestTime": "2019-03-14T14:54:20+00:00", "LatestTime": null, "AllowEmpty": false}', json.dumps(test_field.to_json())) + self.assertEqual('{"Path": "a.b.c", "Type": "timestamp", "UpperLimit": null, "LowerLimit": null, "Values": null, "EqualsValue": null, "EarliestTime": "2019-03-14T14:54:20+00:00", "LatestTime": null, "AllowEmpty": false}', str(test_field))