113 lines
3.3 KiB
Python
113 lines
3.3 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import timedelta
|
|
from decimal import Decimal
|
|
|
|
import pytest
|
|
from django.contrib.auth import get_user_model
|
|
from django.utils import timezone
|
|
|
|
from apps.profiles.models import SearchProfile
|
|
from apps.sources.models import Source, SourcePolicyReview, SourceRobotsCache
|
|
|
|
|
|
@pytest.fixture
|
|
def user(db):
|
|
return get_user_model().objects.create_user(
|
|
username="jens",
|
|
email="jens@example.invalid",
|
|
password="correct-horse-battery-staple",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def profile(user):
|
|
return SearchProfile.objects.create(
|
|
user=user,
|
|
name="Testprofiel",
|
|
is_active=True,
|
|
home_municipality="Hasselt",
|
|
home_latitude=Decimal("50.930700"),
|
|
home_longitude=Decimal("5.332500"),
|
|
max_distance_km=50,
|
|
learning_enabled=True,
|
|
desired_titles=["infrastructure engineer", "systeembeheerder"],
|
|
excluded_titles=["sales", "recruiter"],
|
|
desired_skills=["Microsoft 365", "VMware"],
|
|
allowed_employment_types=["full_time", "permanent"],
|
|
preferred_workplace=["hybrid", "on_site"],
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def source(db):
|
|
source = Source.objects.create(
|
|
name="Example jobs",
|
|
source_type=Source.Type.EMPLOYER,
|
|
base_url="https://jobs.example.org/vacatures/",
|
|
domain="jobs.example.org",
|
|
status=Source.Status.ACTIVE,
|
|
policy=Source.Policy.ALLOW,
|
|
)
|
|
SourcePolicyReview.objects.create(
|
|
source=source,
|
|
decision=SourcePolicyReview.Decision.ALLOW,
|
|
reason="Testbron expliciet toegestaan",
|
|
expires_at=timezone.now() + timedelta(days=1),
|
|
)
|
|
SourceRobotsCache.objects.create(
|
|
origin="https://jobs.example.org",
|
|
expires_at=timezone.now() + timedelta(days=1),
|
|
allow_rules={"*": ["/"]},
|
|
disallow_rules={},
|
|
)
|
|
return source
|
|
|
|
|
|
@pytest.fixture
|
|
def employer(db):
|
|
from apps.jobs.models import Employer
|
|
|
|
return Employer.objects.create(
|
|
name="Example IT",
|
|
normalized_name="example it",
|
|
domain="jobs.example.org",
|
|
is_direct_employer=True,
|
|
is_recruiter=False,
|
|
confidence=0.9,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def job(db, employer):
|
|
from apps.jobs.models import JobPosting
|
|
|
|
return JobPosting.objects.create(
|
|
employer=employer,
|
|
original_title="Infrastructure Engineer",
|
|
normalized_title="infrastructure engineer",
|
|
job_family="infrastructure",
|
|
canonical_url="https://jobs.example.org/vacatures/infrastructure-engineer",
|
|
canonical_key="c" * 64,
|
|
content_hash="d" * 64,
|
|
description_text=(
|
|
"Beheer Microsoft 365 en VMware. Hybride werk met beperkte tweedelijnssupport."
|
|
),
|
|
raw_location="Hasselt, Limburg",
|
|
region="Limburg",
|
|
municipality="Hasselt",
|
|
workplace_type=JobPosting.Workplace.HYBRID,
|
|
employment_types=["full_time", "permanent"],
|
|
skills_required=["Microsoft 365"],
|
|
skills_preferred=["VMware"],
|
|
direct_employer=True,
|
|
recruiter=False,
|
|
extraction_confidence=0.9,
|
|
analysis_features={
|
|
"support_ratio": 0.1,
|
|
"public_sector_signal": 0.0,
|
|
"experience_years_max": 3,
|
|
},
|
|
status=JobPosting.Status.ACTIVE,
|
|
)
|