Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install . pytest pytest-cov
pip install -e . pytest pytest-cov

- name: Run Pytest with Coverage
run: |
pytest --cov=faker_pk --cov-report=html --cov-report=xml

PYTHONPATH=. pytest --cov=faker_pk --cov-report=html --cov-report=xml
- name: Upload Coverage Report Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 🇵🇰 faker-pk
# faker-pk
![PyPI Version](https://img.shields.io/pypi/v/faker-pk)
![PyPI downloads](https://img.shields.io/pypi/dm/faker-pk)
![Python Version](https://img.shields.io/pypi/pyversions/faker-pk)
Expand Down
37 changes: 37 additions & 0 deletions tests/test_provider_methods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from faker import Faker
import pytest
from faker_pk import FakerPKProvider, FakerPK

def test_faker_pk_provider_multiple_count():
fake = Faker()
fake.add_provider(FakerPKProvider)

# Test count > 1 branches in provider.py
assert len(fake.pk_male_name(count=2)) == 2
assert len(fake.pk_female_name(count=2)) == 2
assert len(fake.pk_cnic(count=2)) == 2
assert len(fake.pk_phone_number(count=2)) == 2
assert len(fake.pk_sim_provider(count=2)) == 2
assert len(fake.pk_caste(count=2)) == 2
assert len(fake.pk_sect(count=2)) == 2
assert len(fake.pk_dob(count=2)) == 2
assert len(fake.pk_city(count=2)) == 2
assert len(fake.pk_province(count=2)) == 2
assert len(fake.pk_full_address(count=2)) == 2
assert len(fake.pk_company_name(count=2)) == 2
assert len(fake.pk_industry_name(count=2)) == 2
assert len(fake.pk_bank_name(count=2)) == 2
assert len(fake.pk_iban(count=2)) == 2
assert len(fake.pk_job_title(count=2)) == 2
assert len(fake.pk_job_title_with_industry(count=2)) == 2
assert len(fake.pk_salary(count=2)) == 2
assert len(fake.institution(count=2)) == 2
assert len(fake.student_profile(count=2)) == 2

def test_faker_pk_edge_cases():
fpk = FakerPK()
# Test invalid gender fallback in cnic
assert fpk.cnic(gender="invalid") is not None
# Test invalid industry raises ValueError
with pytest.raises(ValueError):
fpk.salary(industry="NonExistentIndustry")
11 changes: 11 additions & 0 deletions tests/test_student_profile_gender_cnic_alignment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from faker_pk import FakerPK

def test_student_profile_gender_cnic_alignment(faker_pk: FakerPK):
for _ in range(20):
profile = faker_pk.student_profile()
gender = profile["gender"]
last_digit = int(profile["cnic"][-1])
if gender == "male":
assert last_digit % 2 == 1, f"Male CNIC should end with an odd digit, got {profile['cnic']}"
else:
assert last_digit % 2 == 0, f"Female CNIC should end with an even digit, got {profile['cnic']}"
9 changes: 9 additions & 0 deletions tests/test_student_profile_multiple_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from faker_pk import FakerPK

def test_student_profile_multiple_count(faker_pk: FakerPK):
profiles = faker_pk.student_profile(count=5)
assert isinstance(profiles, list)
assert len(profiles) == 5
for p in profiles:
assert isinstance(p, dict)
assert "institution" in p
Loading