-
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.
test: create unit tests candidate model (#11)
- Loading branch information
Showing
1 changed file
with
70 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,70 @@ | ||
import pytest | ||
|
||
from candidates.models import Candidate | ||
from offer.models import JobOffer | ||
from users.models import UserAccount | ||
|
||
|
||
@pytest.fixture | ||
def job_offer_instance(): | ||
return JobOffer.objects.create( | ||
title="Test Job Offer", | ||
description="Test Job Offer Description", | ||
is_remote=True, | ||
is_hybrid=False, | ||
skills="Test Skills", | ||
company_logo="test_logo.png", | ||
company_name="Test Company", | ||
url="http://testjoboffer.com" | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def user_account_instance(): | ||
return UserAccount.objects.create( | ||
first_name="testuser", | ||
last_name="xxx", | ||
email="[email protected]", | ||
password="testpassword" | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def candidate_instance(job_offer_instance, user_account_instance): | ||
return Candidate.objects.create( | ||
first_name="John", | ||
last_name="Doe", | ||
email="[email protected]", | ||
phone="123456789", | ||
future_recruitment=False, | ||
message="Test Message", | ||
job_offer=job_offer_instance, | ||
user=user_account_instance, | ||
status="PENDING", | ||
) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_candidate_model(candidate_instance, job_offer_instance, user_account_instance): | ||
assert candidate_instance.first_name == "John" | ||
assert candidate_instance.last_name == "Doe" | ||
assert candidate_instance.email == "[email protected]" | ||
assert candidate_instance.phone == "123456789" | ||
assert candidate_instance.future_recruitment is False | ||
assert candidate_instance.message == "Test Message" | ||
assert candidate_instance.job_offer == job_offer_instance | ||
assert candidate_instance.user == user_account_instance | ||
assert candidate_instance.status == "PENDING" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_candidate_model_blank_fields(job_offer_instance): | ||
candidate = Candidate.objects.create( | ||
first_name="John", | ||
last_name="Doe", | ||
email="[email protected]", | ||
phone="123456789", | ||
job_offer=job_offer_instance | ||
) | ||
assert candidate.message is None | ||
assert candidate.user is None |