mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-09-17 00:26:26 +00:00
Fix salary tool edge cases (#75)
* fix: handle salary tool edge cases * fix: preserve Danish salary compounds
This commit is contained in:
@@ -37,6 +37,13 @@ class DetectColumnTypeTests(unittest.TestCase):
|
||||
with self.subTest(header=header):
|
||||
self.assertEqual(detect_column_type(header), "count")
|
||||
|
||||
def test_count_inside_word_does_not_make_count_header(self):
|
||||
self.assertIsNone(detect_column_type("Accounting Total"))
|
||||
self.assertEqual(detect_column_type("Accounting Index"), "index")
|
||||
|
||||
def test_danish_compound_headers_still_match(self):
|
||||
self.assertEqual(detect_column_type("Lønindeks"), "index")
|
||||
|
||||
def test_parse_sheet_preserves_category_name_with_letter_n(self):
|
||||
ws = FakeWorksheet([
|
||||
("Company", "Engineering Count", "Engineering Index"),
|
||||
@@ -47,6 +54,16 @@ class DetectColumnTypeTests(unittest.TestCase):
|
||||
|
||||
self.assertEqual(companies[0]["categories"]["engineering"], {"count": 12, "index": 105.5})
|
||||
|
||||
def test_parse_sheet_groups_accounting_count_index_pair(self):
|
||||
ws = FakeWorksheet([
|
||||
("Company", "Accounting Count", "Accounting Index"),
|
||||
("Example Corp", 12, 105.5),
|
||||
])
|
||||
|
||||
companies = parse_sheet(ws)
|
||||
|
||||
self.assertEqual(companies[0]["categories"]["accounting"], {"count": 12, "index": 105.5})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import unittest
|
||||
|
||||
from salary_lookup import format_entry
|
||||
|
||||
|
||||
class FormatEntryTests(unittest.TestCase):
|
||||
def test_zero_count_is_displayed_as_zero(self):
|
||||
entry = {
|
||||
"company": "Example Corp",
|
||||
"city": "",
|
||||
"categories": {
|
||||
"public_data": {
|
||||
"count": 0,
|
||||
"index": 100.0,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
rendered = format_entry(entry, {"index_baseline": 100, "index_label": "Index"})
|
||||
|
||||
self.assertRegex(rendered, r"Public Data\s+0\s+100\.0")
|
||||
|
||||
def test_text_index_does_not_crash(self):
|
||||
entry = {
|
||||
"company": "Example Corp",
|
||||
"city": "",
|
||||
"categories": {
|
||||
"sample": {
|
||||
"count": 3,
|
||||
"index": "private",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
rendered = format_entry(entry, {"index_baseline": 100, "index_label": "Index"})
|
||||
|
||||
self.assertIn("private", rendered)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user