-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YDA-5584: support header column suffixes in some situations
- Loading branch information
Showing
4 changed files
with
66 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
category,subcategory,groupname,manager,member,member,viewer | ||
test-automation,csv-test,csv-test-group1,[email protected],[email protected],[email protected],[email protected] | ||
test-automation,csv-test,csv-test-group2,[email protected],[email protected],[email protected],[email protected] | ||
test-automation,csv-test,csv-test-group3,[email protected],[email protected],[email protected],[email protected] | ||
test-automation,csv-test,csv-test-group4,[email protected],[email protected],[email protected],[email protected] |
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 @@ | ||
category,subcategory,groupname,manager:alice,member:bob,member:charlie,viewer:dan | ||
test-automation,csv-test,csv-test-group1,[email protected],[email protected],[email protected],[email protected] | ||
test-automation,csv-test,csv-test-group2,[email protected],[email protected],[email protected],[email protected] |
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 |
---|---|---|
|
@@ -31,7 +31,7 @@ def test_fully_filled_csv_line_1_9(self): | |
"manager": ["[email protected]"], | ||
"member": ["[email protected]"], | ||
"viewer": ["[email protected]"], | ||
"expiration_date": ["2025-01-01"], | ||
"expiration_date": ["2030-01-01"], | ||
"schema_id": ["default-3"], | ||
} | ||
expected = ( | ||
|
@@ -42,7 +42,34 @@ def test_fully_filled_csv_line_1_9(self): | |
["[email protected]"], | ||
["[email protected]"], | ||
"default-3", | ||
"2025-01-01", | ||
"2030-01-01", | ||
) | ||
result, error_msg = _process_csv_line(d, args, "1.9") | ||
self.assertTupleEqual(expected, result) | ||
self.assertIsNone(error_msg) | ||
|
||
def test_fully_filled_csv_line_1_9_with_suffixes(self): | ||
# Confirm support the old csv header format still (with ":nicknameofuser") | ||
args = {"offline_check": True} | ||
d = { | ||
"category": ["test-automation"], | ||
"subcategory": ["initial"], | ||
"groupname": ["groupteama"], | ||
"manager:alice": ["[email protected]"], | ||
"member:bob": ["[email protected]"], | ||
"viewer:eve": ["[email protected]"], | ||
"expiration_date": ["2030-01-01"], | ||
"schema_id": ["default-3"], | ||
} | ||
expected = ( | ||
"test-automation", | ||
"initial", | ||
"research-groupteama", | ||
["[email protected]"], | ||
["[email protected]"], | ||
["[email protected]"], | ||
"default-3", | ||
"2030-01-01", | ||
) | ||
result, error_msg = _process_csv_line(d, args, "1.9") | ||
self.assertTupleEqual(expected, result) | ||
|
@@ -129,6 +156,19 @@ def test_error_fields_1_8(self): | |
self.assertIsNone(result) | ||
self.assertIn("1.9", error_msg) | ||
|
||
def test_parse_csv(self): | ||
args = {"offline_check": True} | ||
parse_csv_file("files/csv-import-test.csv", args, "1.9") | ||
|
||
@patch('sys.stderr', new_callable=StringIO) | ||
def test_parse_csv_with_header_suffixes(self, mock_stderr): | ||
args = {"offline_check": True} | ||
parse_csv_file("files/header-with-suffixes.csv", args, "1.8") | ||
|
||
# This header format not supported in 1.9 and higher | ||
with self.assertRaises(SystemExit): | ||
parse_csv_file("files/header-with-suffixes.csv", args, "1.9") | ||
|
||
@patch('sys.stderr', new_callable=StringIO) | ||
def test_parse_invalid_csv_file(self, mock_stderr): | ||
# csv that has an unlabeled header | ||
|
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