Skip to content

Commit

Permalink
Update test_job_application_profile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
queukat authored Oct 4, 2024
1 parent 029bbdb commit 48e1aa1
Showing 1 changed file with 44 additions and 35 deletions.
79 changes: 44 additions & 35 deletions tests/test_job_application_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
def valid_yaml():
"""Valid YAML string for initializing JobApplicationProfile."""
return """
personal_information:
name: John
surname: Doe
date_of_birth: "1990-01-01"
country: USA
city: New York
address: "123 Main St"
phone_prefix: "+1"
phone: "1234567890"
email: john.doe@example.com
github: "github.com/johndoe"
linkedin: "linkedin.com/in/johndoe"
self_identification:
gender: Male
pronouns: He/Him
Expand Down Expand Up @@ -41,10 +53,23 @@ def valid_yaml():
salary_range_usd: "80000-120000"
"""


@pytest.fixture
def missing_field_yaml():
"""YAML string missing a required field (self_identification)."""
return """
personal_information:
name: John
surname: Doe
date_of_birth: "1990-01-01"
country: USA
city: New York
address: "123 Main St"
phone_prefix: "+1"
phone: "1234567890"
email: john.doe@example.com
github: "github.com/johndoe"
linkedin: "linkedin.com/in/johndoe"
legal_authorization:
eu_work_authorization: "Yes"
us_work_authorization: "Yes"
Expand Down Expand Up @@ -75,10 +100,23 @@ def missing_field_yaml():
salary_range_usd: "80000-120000"
"""


@pytest.fixture
def invalid_type_yaml():
"""YAML string with an invalid type for a field."""
return """
personal_information:
name: John
surname: Doe
date_of_birth: "1990-01-01"
country: USA
city: New York
address: "123 Main St"
phone_prefix: "+1"
phone: "1234567890"
email: john.doe@example.com
github: "github.com/johndoe"
linkedin: "linkedin.com/in/johndoe"
self_identification:
gender: Male
pronouns: He/Him
Expand Down Expand Up @@ -115,6 +153,7 @@ def invalid_type_yaml():
salary_range_usd: "80000-120000"
"""


def test_initialize_with_valid_yaml(valid_yaml):
"""Test initializing JobApplicationProfile with valid YAML."""
profile = JobApplicationProfile(valid_yaml)
Expand All @@ -127,49 +166,19 @@ def test_initialize_with_valid_yaml(valid_yaml):
assert profile.availability.notice_period == "2 weeks"
assert profile.salary_expectations.salary_range_usd == "80000-120000"


def test_initialize_with_missing_field(missing_field_yaml):
"""Test initializing JobApplicationProfile with missing required fields."""
with pytest.raises(KeyError) as excinfo:
JobApplicationProfile(missing_field_yaml)
assert "self_identification" in str(excinfo.value)

def test_initialize_with_invalid_yaml():
"""Test initializing JobApplicationProfile with invalid YAML."""
invalid_yaml_str = """
self_identification:
gender: Male
pronouns: He/Him
veteran: No
disability: No
ethnicity: Asian
legal_authorization:
eu_work_authorization: "Yes"
us_work_authorization: "Yes"
requires_us_visa: "No"
requires_us_sponsorship: "Yes"
requires_eu_visa: "No"
legally_allowed_to_work_in_eu: "Yes"
legally_allowed_to_work_in_us: "Yes"
requires_eu_sponsorship: "No"
canada_work_authorization: "Yes"
requires_canada_visa: "No"
legally_allowed_to_work_in_canada: "Yes"
requires_canada_sponsorship: "No"
uk_work_authorization: "Yes"
requires_uk_visa: "No"
legally_allowed_to_work_in_uk: "Yes"
requires_uk_sponsorship: "No"
work_preferences:
remote_work: "Yes"
in_person_work: "No"
availability:
notice_period: "2 weeks"
salary_expectations:
salary_range_usd: "80000-120000"
""" # Missing fields in work_preferences

def test_initialize_with_invalid_yaml(invalid_type_yaml):
"""Test initializing JobApplicationProfile with invalid YAML field type."""
with pytest.raises(TypeError):
JobApplicationProfile(invalid_yaml_str)
JobApplicationProfile(invalid_type_yaml)


def test_str_representation(valid_yaml):
"""Test the string representation of JobApplicationProfile."""
Expand Down

0 comments on commit 48e1aa1

Please sign in to comment.