forked from NCSU-SE-2024/PackReview_v3
-
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
Showing
3 changed files
with
152 additions
and
0 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,4 @@ | ||
name,age,city | ||
John,30,New York | ||
Anna,22,London | ||
Mike,32,San Francisco |
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 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,96 @@ | ||
import unittest | ||
from collections import defaultdict | ||
from app.routes import transform_jobs # Adjust the import based on your project structure | ||
|
||
class TestTransformJobs(unittest.TestCase): | ||
def test_transform_jobs(self): | ||
"""Test the transform_jobs function.""" | ||
jobs = [ | ||
{ | ||
'title': 'Software Engineer', | ||
'company': 'Company A', | ||
'locations': 'Location 1', | ||
'department': 'Engineering', | ||
'salary': 100000, | ||
'experience': 5 | ||
}, | ||
{ | ||
'title': 'Software Engineer', | ||
'company': 'Company A', | ||
'locations': 'Location 1', | ||
'department': 'Engineering', | ||
'salary': 110000, | ||
'experience': 6 | ||
}, | ||
{ | ||
'title': 'Data Scientist', | ||
'company': 'Company B', | ||
'locations': 'Location 2', | ||
'department': 'Data', | ||
'salary': 120000, | ||
'experience': 4 | ||
} | ||
] | ||
|
||
expected_output = [ | ||
{ | ||
'title': 'Software Engineer', | ||
'company': 'Company A', | ||
'locations': 'Location 1', | ||
'department': 'Engineering', | ||
'other_attributes': [ | ||
{'salary': 100000, 'experience': 5}, | ||
{'salary': 110000, 'experience': 6} | ||
] | ||
}, | ||
{ | ||
'title': 'Data Scientist', | ||
'company': 'Company B', | ||
'locations': 'Location 2', | ||
'department': 'Data', | ||
'other_attributes': [ | ||
{'salary': 120000, 'experience': 4} | ||
] | ||
} | ||
] | ||
|
||
result = transform_jobs(jobs) | ||
self.assertEqual(result, expected_output) | ||
|
||
def test_transform_jobs_empty(self): | ||
"""Test the transform_jobs function with an empty list.""" | ||
jobs = [] | ||
expected_output = [] | ||
result = transform_jobs(jobs) | ||
self.assertEqual(result, expected_output) | ||
|
||
def test_transform_jobs_single_entry(self): | ||
"""Test the transform_jobs function with a single job entry.""" | ||
jobs = [ | ||
{ | ||
'title': 'Software Engineer', | ||
'company': 'Company A', | ||
'locations': 'Location 1', | ||
'department': 'Engineering', | ||
'salary': 100000, | ||
'experience': 5 | ||
} | ||
] | ||
|
||
expected_output = [ | ||
{ | ||
'title': 'Software Engineer', | ||
'company': 'Company A', | ||
'locations': 'Location 1', | ||
'department': 'Engineering', | ||
'other_attributes': [ | ||
{'salary': 100000, 'experience': 5} | ||
] | ||
} | ||
] | ||
|
||
result = transform_jobs(jobs) | ||
self.assertEqual(result, expected_output) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |