more unit tests for add-id
@@ -19,3 +19,19 @@ class TestKGTKAddID(unittest.TestCase):
df = pd.read_csv(f'{self.temp_dir}/id.tsv',sep='\t')
for i, row in df.iterrows():
self.assertEqual(row['id'], f'E{i+1}')
+
+ def test_kgtk_add_id_overwrite_existing_id(self):
+ file_path = 'data/sample_kgtk_edge_file_with_id.tsv'
+ cli_entry("kgtk", "add-id", "-i", file_path, "-o", f'{self.temp_dir}/id.tsv',
+ "--overwrite-id")
+ df = pd.read_csv(f'{self.temp_dir}/id.tsv',sep='\t')
+ for i, row in df.iterrows():
+ self.assertEqual(row['id'], f'E{i+1}')
+
+ def test_kgtk_add_id_new_id_columns(self):
+ file_path = 'data/sample_kgtk_edge_file_with_id.tsv'
+ cli_entry("kgtk", "add-id", "-i", file_path, "-o", f'{self.temp_dir}/id.tsv',
+ "--old-id-column-name", "id", "--new-id-column-name", "id_new")
+ df = pd.read_csv(f'{self.temp_dir}/id.tsv',sep='\t')
+ for i, row in df.iterrows():
+ self.assertEqual(row['id_new'], f'E{i+1}')
