diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c185f77..941ef9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/README.md b/README.md index f118c87..c8feff3 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/tests/test_provider_methods.py b/tests/test_provider_methods.py new file mode 100644 index 0000000..46ce3a5 --- /dev/null +++ b/tests/test_provider_methods.py @@ -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") \ No newline at end of file diff --git a/tests/test_student_profile_gender_cnic_alignment.py b/tests/test_student_profile_gender_cnic_alignment.py new file mode 100644 index 0000000..98e42af --- /dev/null +++ b/tests/test_student_profile_gender_cnic_alignment.py @@ -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']}" \ No newline at end of file diff --git a/tests/test_student_profile_multiple_count.py b/tests/test_student_profile_multiple_count.py new file mode 100644 index 0000000..5ef9245 --- /dev/null +++ b/tests/test_student_profile_multiple_count.py @@ -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 \ No newline at end of file