moving from unittest to pytest

This commit is contained in:
Sina Atalay 2024-01-18 23:38:19 +01:00
parent b5b0e284e2
commit 2e54d762dc
2 changed files with 45 additions and 19 deletions

0
tests/conftest.py Normal file
View File

View File

@ -1,33 +1,59 @@
import unittest
import os
import json
import pytest
from rendercv import data_models
from datetime import date as Date
from pydantic import ValidationError
from rendercv import data_models as dm
def test_sections():
input = {
@pytest.fixture(scope="module")
def dummy_input():
return {
"name": "John Doe",
"sections": {
"my_section": {
"title": "test",
"sections": None,
}
# abi burda baya bi senaryo test etmen lazim:
# mesela section icinde title field verilmisse, title o olamli, herseyo overwrite etmeli
# sonra siralama listede verildigi gibi olmali kesinlikle bunu da check et
# sonra default listler alisiyo mu kesinlikle onu check etmek lazim
# bide validation errorleri check etmek lazim
def test_education_entry(dummy_input):
dummy_input["sections"] = {
"My Section": [
{
"entry_type": "EducationEntry",
"entries": [
{
"institution": "Boğaziçi University",
"start_date": "2019-01-01",
"end_date": "2020-01-01",
"area": "Mechanical Engineering",
"date": "My Date",
}
],
}
},
]
}
cv = data_models.CurriculumVitae(**input)
assert cv is not None
assert cv.sections[0].entry_type == "EducationEntry"
assert len(cv.sections_input["my_section"].entries) == 1
cv = dm.CurriculumVitae(**dummy_input)
assert cv.sections[0].title == "My Section"
assert len(cv.sections[0].entries) == 1
def test_experience_entry(dummy_input):
dummy_input["sections"] = {
"My Section": [
{
"entry_type": "ExperienceEntry",
"entries": [
{
"company": "CERN",
"start_date": "2019-01-01",
"end_date": "2020-01-01",
"position": "Researcher",
}
],
}
]
}
cv = dm.CurriculumVitae(**dummy_input)
assert cv.sections[0].title == "My Section"
assert len(cv.sections[0].entries) == 1