-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29c16ff
commit 48600e9
Showing
4 changed files
with
52 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Type,Record Identifier,Field,Source Value,Target Value | ||
Missing in Target,1,,, | ||
Missing in Source,3,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import unittest | ||
import csv | ||
import os | ||
from reconciler import Reconciler, ReconciliationReport | ||
|
||
class TestReconciler(unittest.TestCase): | ||
def setUp(self): | ||
# Create sample CSV files for testing | ||
self.source_csv_path = 'test_source.csv' | ||
self.target_csv_path = 'test_target.csv' | ||
self.output_csv_path = 'test_output.csv' | ||
|
||
self.create_sample_csv(self.source_csv_path, [{'ID': '1', 'Name': 'John'}, {'ID': '2', 'Name': 'Alice'}]) | ||
self.create_sample_csv(self.target_csv_path, [{'ID': '2', 'Name': 'Alice'}, {'ID': '3', 'Name': 'Bob'}]) | ||
|
||
def tearDown(self): | ||
# Remove sample CSV files after testing | ||
os.remove(self.source_csv_path) | ||
os.remove(self.target_csv_path) | ||
|
||
|
||
def create_sample_csv(self, file_path, data): | ||
with open(file_path, 'w', newline='') as file: | ||
writer = csv.DictWriter(file, fieldnames=['ID', 'Name']) | ||
writer.writeheader() | ||
writer.writerows(data) | ||
|
||
def test_reconciliation_with_discrepancies(self): | ||
rc = Reconciler(self.source_csv_path, self.target_csv_path) | ||
report = rc.reconcile_data() | ||
|
||
self.assertIsInstance(report, ReconciliationReport) | ||
self.assertTrue(report.missing_in_target) | ||
self.assertTrue(report.missing_in_source) | ||
self.assertTrue(report.discrepancies) | ||
|
||
|
||
def test_report_generation(self): | ||
rc = Reconciler(self.source_csv_path, self.target_csv_path) | ||
report = rc.reconcile_data() | ||
report.generate_report(self.output_csv_path) | ||
|
||
self.assertTrue(os.path.exists(self.output_csv_path)) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |