def test_job_posting_weird_region(): fake_job = { 'jobLocation': { 'address': { 'addressLocality': 'Any City', 'addressRegion': 'Northeastern USA' } } } assert job_posting_search_strings(fake_job) ==\ ['Any City, Northeastern USA']
def test_job_posting_search_string_no_location(): assert job_posting_search_strings({}) == []
def test_job_posting_search_string_bad_address(): fake_job = {'jobLocation': {'address': {}}} assert job_posting_search_strings(fake_job) == []
def test_job_posting_search_string_only_city(): fake_job = {'jobLocation': {'address': {'addressLocality': 'City'}}} assert job_posting_search_strings(fake_job) == ['City']
def test_job_posting_search_strings(): with open('sample_job_listing.json') as f: sample_job_posting = json.load(f) assert sorted(job_posting_search_strings(sample_job_posting)) == sorted( ['Salisbury, Pennsylvania', 'Salisbury, PA'])