data-seed-ph 3.2.2__tar.gz → 3.4.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {data_seed_ph-3.2.2/data_seed_ph.egg-info → data_seed_ph-3.4.2}/PKG-INFO +2 -2
  2. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/README.md +1 -1
  3. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2/data_seed_ph.egg-info}/PKG-INFO +2 -2
  4. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/data_seed_ph.egg-info/SOURCES.txt +1 -4
  5. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/pyproject.toml +1 -1
  6. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/__init__.py +1 -1
  7. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/core.py +58 -7
  8. data_seed_ph-3.2.2/tests/test_core.py +0 -186
  9. data_seed_ph-3.2.2/tests/test_exporter.py +0 -75
  10. data_seed_ph-3.2.2/tests/test_providers.py +0 -258
  11. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/LICENSE +0 -0
  12. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/MANIFEST.in +0 -0
  13. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/data_seed_ph.egg-info/dependency_links.txt +0 -0
  14. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/data_seed_ph.egg-info/requires.txt +0 -0
  15. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/data_seed_ph.egg-info/top_level.txt +0 -0
  16. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/exports/__init__.py +0 -0
  17. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/exports/exporter.py +0 -0
  18. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/__init__.py +0 -0
  19. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/domains.json +0 -0
  20. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/educations.json +0 -0
  21. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/first_names.json +0 -0
  22. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/last_names.json +0 -0
  23. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/luzon_locations.json +0 -0
  24. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/mindanao_locations.json +0 -0
  25. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/preferences.json +0 -0
  26. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/source.md +0 -0
  27. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data/visayas_locations.json +0 -0
  28. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/seed/providers/data_provider.py +0 -0
  29. {data_seed_ph-3.2.2 → data_seed_ph-3.4.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: data-seed-ph
3
- Version: 3.2.2
3
+ Version: 3.4.2
4
4
  Summary: A Python library for generating realistic, synthetic Philippine-based datasets.
5
5
  Author-email: "Christian G. Garcia" <iyaniyan03112003@gmail.com>
6
6
  License-Expression: MIT
@@ -40,4 +40,4 @@ Dynamic: license-file
40
40
  >[!NOTE]
41
41
  > Designed for database seeding, API testing, machine learning dataset generation, academic research, and software development prototyping with support for CSV, JSON and SQL export formats.
42
42
 
43
- View full documentation: [Github](https://github.com/christiangarcia0311/data-seed-ph)
43
+ [View full documentation](https://github.com/christiangarcia0311/data-seed-ph)
@@ -15,4 +15,4 @@
15
15
  >[!NOTE]
16
16
  > Designed for database seeding, API testing, machine learning dataset generation, academic research, and software development prototyping with support for CSV, JSON and SQL export formats.
17
17
 
18
- View full documentation: [Github](https://github.com/christiangarcia0311/data-seed-ph)
18
+ [View full documentation](https://github.com/christiangarcia0311/data-seed-ph)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: data-seed-ph
3
- Version: 3.2.2
3
+ Version: 3.4.2
4
4
  Summary: A Python library for generating realistic, synthetic Philippine-based datasets.
5
5
  Author-email: "Christian G. Garcia" <iyaniyan03112003@gmail.com>
6
6
  License-Expression: MIT
@@ -40,4 +40,4 @@ Dynamic: license-file
40
40
  >[!NOTE]
41
41
  > Designed for database seeding, API testing, machine learning dataset generation, academic research, and software development prototyping with support for CSV, JSON and SQL export formats.
42
42
 
43
- View full documentation: [Github](https://github.com/christiangarcia0311/data-seed-ph)
43
+ [View full documentation](https://github.com/christiangarcia0311/data-seed-ph)
@@ -21,7 +21,4 @@ seed/providers/data/luzon_locations.json
21
21
  seed/providers/data/mindanao_locations.json
22
22
  seed/providers/data/preferences.json
23
23
  seed/providers/data/source.md
24
- seed/providers/data/visayas_locations.json
25
- tests/test_core.py
26
- tests/test_exporter.py
27
- tests/test_providers.py
24
+ seed/providers/data/visayas_locations.json
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "data-seed-ph"
7
- version = "3.2.2"
7
+ version = "3.4.2"
8
8
  description = "A Python library for generating realistic, synthetic Philippine-based datasets."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -11,5 +11,5 @@ Information
11
11
 
12
12
  from .core import Dataset
13
13
 
14
- __version__ = '3.2.1'
14
+ __version__ = '3.4.0'
15
15
  __all__ = ['Dataset']
@@ -34,6 +34,7 @@ from .providers.data_provider import (
34
34
  import pandas as pd
35
35
  import numpy as np
36
36
  import random as rd
37
+ import os
37
38
 
38
39
 
39
40
 
@@ -89,6 +90,12 @@ class Dataset:
89
90
  'strand': lambda: self.data.education.strand()
90
91
  }
91
92
 
93
+ def _reset_providers(self):
94
+ self.data.personal = PersonalDataProvider()
95
+ self.data.address = AddressDataProvider()
96
+ self.data.contact = ContactDataProvider(self.data.personal)
97
+ self.data.education = EducationDataProvider()
98
+
92
99
  def generate(self, rows: int, features: dict) -> pd.DataFrame:
93
100
  self.dump = {feature: [] for feature in features}
94
101
 
@@ -132,6 +139,33 @@ class Dataset:
132
139
 
133
140
  return pd.DataFrame(self.dump)
134
141
 
142
+ '''
143
+ v.3.4.2: [feat #1] Batch Generation with Variations
144
+ ----------------------------------------------------
145
+ '''
146
+
147
+ def generate_batch(self, configurations: list) -> dict:
148
+ batch_results: dict = {}
149
+
150
+ for index, config in enumerate(configurations):
151
+
152
+ if not isinstance(config, dict): raise ValueError(f'Configuration at index {index} must be a dictionary format.')
153
+ if 'rows' not in config or 'features' not in config: raise ValueError(f'Configuration at index {index} must contain `features` keys and `rows`')
154
+
155
+ batch_name = config.get('name', f'batch_{index + 1}')
156
+
157
+ rows = config['rows']
158
+ features = config['features']
159
+
160
+ if not isinstance(rows, int) or rows <= 0: raise ValueError(f'Batch {batch_name} must be a postive integer.')
161
+ if not isinstance(features, dict) or not features: raise ValueError(f'Batch {batch_name}: features cannot be empty dictionary.')
162
+
163
+ self._reset_providers()
164
+
165
+ batch_results[batch_name] = self.generate(rows=rows, features=features)
166
+
167
+ return batch_results
168
+
135
169
  def save(
136
170
  self,
137
171
  data: dict,
@@ -182,10 +216,27 @@ class Dataset:
182
216
  raise ValueError(f'Unsupported database type: {database_type}')
183
217
  case _:
184
218
  raise ValueError(f'Unsupported format: {format}')
185
-
186
-
187
- '''
188
- For future implementation
189
-
190
- @author: Christian G. Garcia
191
- '''
219
+
220
+ def save_batch(
221
+ self,
222
+ batch_data: dict,
223
+ format: str,
224
+ output_dir: str = './output',
225
+ **kwargs
226
+ ):
227
+ os.makedirs(output_dir, exist_ok=True)
228
+
229
+ for batch_name, data in batch_data.items():
230
+ filename = os.path.join(output_dir, batch_name)
231
+
232
+ try:
233
+ self.save(
234
+ data=data,
235
+ filename=filename,
236
+ format=format,
237
+ **kwargs
238
+ )
239
+
240
+ print(f'Batch {batch_name} successfully saved.')
241
+ except Exception as e:
242
+ print(f'Error saving batch {batch_name}: {e}')
@@ -1,186 +0,0 @@
1
- import pytest
2
- import pandas as pd
3
- import tempfile
4
- import os
5
- from seed.core import Dataset, Data
6
- from seed.providers.data_provider import PersonalDataProvider, AddressDataProvider, ContactDataProvider
7
- from seed.exports.exporter import SaveData
8
-
9
- class TestData:
10
- def test_data_initialization(self):
11
- data = Data()
12
- assert isinstance(data.personal, PersonalDataProvider)
13
- assert isinstance(data.address, AddressDataProvider)
14
- assert isinstance(data.contact, ContactDataProvider)
15
-
16
- class TestDataset:
17
- def setup_method(self):
18
- self.dataset = Dataset()
19
-
20
- def test_dataset_initialization(self):
21
- assert isinstance(self.dataset.export, SaveData)
22
- assert isinstance(self.dataset.data, Data)
23
- assert isinstance(self.dataset.dump, dict)
24
- assert len(self.dataset.data_map) > 0
25
-
26
- def test_generate_basic(self):
27
- features = {'firstname': 'firstname', 'lastname': 'lastname'}
28
- result = self.dataset.generate(5, features)
29
- assert isinstance(result, pd.DataFrame)
30
- assert len(result) == 5
31
- assert 'firstname' in result.columns
32
- assert 'lastname' in result.columns
33
-
34
- def test_generate_with_personal_data(self):
35
- features = {
36
- 'full_name': 'fullname',
37
- 'birthdate': 'birthdate',
38
- 'age': 'age'
39
- }
40
- result = self.dataset.generate(10, features)
41
- assert len(result) == 10
42
- for col in features.keys():
43
- assert col in result.columns
44
-
45
- def test_generate_with_address_data(self):
46
- features = {
47
- 'region': 'region',
48
- 'province': 'province',
49
- 'city': 'city'
50
- }
51
- result = self.dataset.generate(5, features)
52
- assert len(result) == 5
53
- assert 'region' in result.columns
54
-
55
- def test_generate_with_all_personal_fields(self):
56
- features = {
57
- 'first': 'firstname',
58
- 'last': 'lastname',
59
- 'suffix': 'suffixname',
60
- 'male': 'malename',
61
- 'female': 'femalename',
62
- 'civil': 'civil',
63
- 'religion': 'religion',
64
- 'blood': 'bloodtype',
65
- 'nationality': 'nationality'
66
- }
67
- result = self.dataset.generate(3, features)
68
- assert len(result) == 3
69
-
70
- def test_generate_with_island_groups(self):
71
- features = {
72
- 'luzon_region': 'luzon',
73
- 'visayas_region': 'visayas',
74
- 'mindanao_region': 'mindanao'
75
- }
76
- result = self.dataset.generate(2, features)
77
- assert len(result) == 2
78
-
79
- def test_generate_with_address_variants(self):
80
- features = {
81
- 'municipality': 'municipality',
82
- 'barangay': 'barangay',
83
- 'full_addr': 'fulladdress',
84
- 'mobile': 'mobile',
85
- 'mobile_intl': 'mobile_int',
86
- 'email': 'email'
87
- }
88
- result = self.dataset.generate(3, features)
89
- assert len(result) == 3
90
-
91
- def test_generate_with_parameterized_province(self):
92
- features = {
93
- 'province': 'province:Surigao Del Norte'
94
- }
95
- result = self.dataset.generate(2, features)
96
- assert len(result) == 2
97
-
98
- def test_generate_with_int_range(self):
99
- features = {
100
- 'score': (10, 100)
101
- }
102
- result = self.dataset.generate(5, features)
103
- assert len(result) == 5
104
- assert all(10 <= val <= 100 for val in result['score'])
105
-
106
- def test_generate_with_float_range(self):
107
- features = {
108
- 'price': (10.5, 99.99, 'float')
109
- }
110
- result = self.dataset.generate(5, features)
111
- assert len(result) == 5
112
- assert all(isinstance(val, float) for val in result['price'])
113
-
114
- def test_generate_with_list_choices(self):
115
- features = {
116
- 'status': ['active', 'inactive', 'pending']
117
- }
118
- result = self.dataset.generate(5, features)
119
- assert len(result) == 5
120
- assert all(val in ['active', 'inactive', 'pending'] for val in result['status'])
121
-
122
- def test_generate_invalid_feature_type(self):
123
- features = {
124
- 'invalid': 12345
125
- }
126
- with pytest.raises(ValueError):
127
- self.dataset.generate(2, features)
128
-
129
- def test_generate_invalid_feature_keyword(self):
130
- features = {
131
- 'bad': 'nonexistent'
132
- }
133
- with pytest.raises(ValueError):
134
- self.dataset.generate(2, features)
135
-
136
- def test_generate_invalid_parameterized_keyword(self):
137
- features = {
138
- 'bad': 'invalid:param'
139
- }
140
- with pytest.raises(ValueError):
141
- self.dataset.generate(2, features)
142
-
143
- def test_save_csv(self):
144
- features = {'name': 'firstname'}
145
- self.dataset.generate(5, features)
146
- temp_dir = tempfile.mkdtemp()
147
- try:
148
- self.dataset.save(self.dataset.dump, os.path.join(temp_dir, 'test'), 'csv')
149
- assert os.path.exists(os.path.join(temp_dir, 'test.csv'))
150
- finally:
151
- for f in os.listdir(temp_dir):
152
- os.remove(os.path.join(temp_dir, f))
153
- os.rmdir(temp_dir)
154
-
155
- def test_save_json(self):
156
- features = {'name': 'firstname'}
157
- self.dataset.generate(3, features)
158
- temp_dir = tempfile.mkdtemp()
159
- try:
160
- self.dataset.save(self.dataset.dump, os.path.join(temp_dir, 'test'), 'json')
161
- assert os.path.exists(os.path.join(temp_dir, 'test.json'))
162
- finally:
163
- for f in os.listdir(temp_dir):
164
- os.remove(os.path.join(temp_dir, f))
165
- os.rmdir(temp_dir)
166
-
167
- def test_save_sql(self):
168
- features = {'name': 'firstname'}
169
- self.dataset.generate(2, features)
170
- temp_dir = tempfile.mkdtemp()
171
- try:
172
- db_path = os.path.join(temp_dir, 'test.db')
173
- self.dataset.save(
174
- self.dataset.dump,
175
- db_path,
176
- 'sql',
177
- table_name='test_table',
178
- database_name=db_path
179
- )
180
- assert os.path.exists(db_path)
181
- finally:
182
- for f in os.listdir(temp_dir):
183
- path = os.path.join(temp_dir, f)
184
- if os.path.isfile(path):
185
- os.remove(path)
186
- os.rmdir(temp_dir)
@@ -1,75 +0,0 @@
1
- import pytest
2
- import os
3
- import tempfile
4
- import pandas as pd
5
- from seed.exports.exporter import SaveData
6
-
7
- class TestSaveData:
8
- def setup_method(self):
9
- self.saver = SaveData()
10
- self.temp_dir = tempfile.mkdtemp()
11
-
12
- def teardown_method(self):
13
- for file in os.listdir(self.temp_dir):
14
- filepath = os.path.join(self.temp_dir, file)
15
- if os.path.isfile(filepath):
16
- os.remove(filepath)
17
- os.rmdir(self.temp_dir)
18
-
19
- def test_to_csv_with_dict(self):
20
- data = {'name': ['John', 'Jane'], 'age': [25, 30]}
21
- filepath = os.path.join(self.temp_dir, 'test.csv')
22
- self.saver.to_csv(data, filepath)
23
- assert os.path.exists(filepath)
24
-
25
- def test_to_csv_with_dataframe(self):
26
- data = pd.DataFrame({'name': ['John', 'Jane'], 'age': [25, 30]})
27
- filepath = os.path.join(self.temp_dir, 'test.csv')
28
- self.saver.to_csv(data, filepath)
29
- assert os.path.exists(filepath)
30
-
31
- def test_to_json_with_dict(self):
32
- data = {'name': ['John', 'Jane'], 'age': [25, 30]}
33
- filepath = os.path.join(self.temp_dir, 'test.json')
34
- self.saver.to_json(data, filepath)
35
- assert os.path.exists(filepath)
36
-
37
- def test_to_json_with_dataframe(self):
38
- data = pd.DataFrame({'name': ['John', 'Jane'], 'age': [25, 30]})
39
- filepath = os.path.join(self.temp_dir, 'test.json')
40
- self.saver.to_json(data, filepath)
41
- assert os.path.exists(filepath)
42
-
43
- def test_invalid_data_type(self, capsys):
44
- self.saver.to_csv([1, 2, 3], os.path.join(self.temp_dir, 'test.csv'))
45
- captured = capsys.readouterr()
46
- assert 'Data must be a dictionary or a pandas DataFrame.' in captured.out
47
-
48
- def test_to_sql_sqlite(self):
49
- data = {'name': ['John', 'Jane'], 'age': [25, 30]}
50
- db_path = os.path.join(self.temp_dir, 'test.db')
51
- self.saver.to_sql(data, 'users', 'sqlite', db_path)
52
- assert os.path.exists(db_path)
53
-
54
- def test_to_sql_with_dataframe(self):
55
- data = pd.DataFrame({'name': ['John', 'Jane'], 'age': [25, 30]})
56
- db_path = os.path.join(self.temp_dir, 'test.db')
57
- self.saver.to_sql(data, 'users', 'sqlite', db_path)
58
- assert os.path.exists(db_path)
59
-
60
- def test_to_sql_custom_primary_key(self):
61
- data = {'user_id': [1, 2], 'name': ['John', 'Jane']}
62
- db_path = os.path.join(self.temp_dir, 'test.db')
63
- self.saver.to_sql(data, 'users', 'sqlite', db_path, primary_key='user_id')
64
- assert os.path.exists(db_path)
65
-
66
- def test_to_json_invalid_data(self, capsys):
67
- self.saver.to_json([1, 2, 3], os.path.join(self.temp_dir, 'test.json'))
68
- captured = capsys.readouterr()
69
- assert 'Data must be a dictionary or a pandas DataFrame.' in captured.out
70
-
71
- def test_to_sql_invalid_database_type(self):
72
- data = {'name': ['John', 'Jane'], 'age': [25, 30]}
73
- db_path = os.path.join(self.temp_dir, 'test.db')
74
- with pytest.raises(ValueError):
75
- self.saver.to_sql(data, 'users', 'postgresql', db_path)
@@ -1,258 +0,0 @@
1
- import pytest
2
- from seed.providers.data_provider import PersonalDataProvider, AddressDataProvider, ContactDataProvider
3
-
4
- class TestPersonalDataProvider:
5
- def setup_method(self):
6
- self.provider = PersonalDataProvider()
7
-
8
- def test_firstname_generation(self):
9
- name = self.provider.firstname()
10
- assert isinstance(name, str)
11
- assert len(name) > 0
12
-
13
- def test_firstname_by_gender(self):
14
- male_name = self.provider.firstname(gender='male')
15
- female_name = self.provider.firstname(gender='female')
16
- assert isinstance(male_name, str)
17
- assert isinstance(female_name, str)
18
-
19
- def test_lastname_generation(self):
20
- name = self.provider.lastname()
21
- assert isinstance(name, str)
22
- assert len(name) > 0
23
-
24
- def test_fullname_generation(self):
25
- fullname = self.provider.fullname()
26
- assert isinstance(fullname, str)
27
- assert len(fullname) > 0
28
-
29
- def test_gender_generation(self):
30
- self.provider.firstname()
31
- gender = self.provider.gender()
32
- assert gender in ['male', 'female']
33
-
34
- def test_birthdate_generation(self):
35
- date = self.provider.birthdate()
36
- assert isinstance(date, str)
37
- assert len(date) > 0
38
-
39
- def test_suffix_generation(self):
40
- suffix = self.provider.suffix()
41
- assert isinstance(suffix, str)
42
-
43
- def test_age_generation(self):
44
- self.provider.birthdate()
45
- age = self.provider.age()
46
- assert isinstance(age, int)
47
- assert age >= 12
48
-
49
- def test_age_without_birthdate(self):
50
- provider = PersonalDataProvider()
51
- with pytest.raises(ValueError):
52
- provider.age()
53
-
54
- def test_civil_generation(self):
55
- civil = self.provider.civil()
56
- assert isinstance(civil, str)
57
-
58
- def test_religion_generation(self):
59
- religion = self.provider.religion()
60
- assert isinstance(religion, str)
61
-
62
- def test_blood_type_generation(self):
63
- blood = self.provider.blood_type()
64
- assert isinstance(blood, str)
65
-
66
- def test_nationality_generation(self):
67
- nationality = self.provider.nationality()
68
- assert isinstance(nationality, str)
69
-
70
- def test_fullname_male(self):
71
- fullname = self.provider.fullname(gender='male')
72
- assert isinstance(fullname, str)
73
- assert len(fullname.split()) >= 2
74
-
75
- def test_fullname_female(self):
76
- fullname = self.provider.fullname(gender='female')
77
- assert isinstance(fullname, str)
78
- assert len(fullname.split()) >= 2
79
-
80
- def test_birthdate_custom_age_range(self):
81
- date = self.provider.birthdate(min_age=18, max_age=65)
82
- assert isinstance(date, str)
83
-
84
- class TestAddressDataProvider:
85
- def setup_method(self):
86
- self.provider = AddressDataProvider()
87
-
88
- def test_region_generation(self):
89
- region = self.provider.region()
90
- assert isinstance(region, str)
91
- assert len(region) > 0
92
-
93
- def test_province_generation(self):
94
- province = self.provider.province()
95
- assert isinstance(province, str)
96
-
97
- def test_city_generation(self):
98
- city = self.provider.city()
99
- assert isinstance(city, str)
100
-
101
- def test_municipality_generation(self):
102
- municipality = self.provider.municipality()
103
- assert isinstance(municipality, str) or municipality is None
104
-
105
- def test_barangay_generation(self):
106
- barangay = self.provider.barangay()
107
- assert isinstance(barangay, str) or barangay is None
108
-
109
- def test_full_address_generation(self):
110
- address = self.provider.full_address()
111
- assert isinstance(address, str)
112
- assert len(address) > 0
113
-
114
- def test_region_with_island_group_luzon(self):
115
- region = self.provider.region('luzon')
116
- assert isinstance(region, str)
117
-
118
- def test_region_with_island_group_visayas(self):
119
- region = self.provider.region('visayas')
120
- assert isinstance(region, str)
121
-
122
- def test_region_with_island_group_mindanao(self):
123
- region = self.provider.region('mindanao')
124
- assert isinstance(region, str)
125
-
126
- def test_province_with_name(self):
127
- self.provider.region()
128
- province = self.provider.province('Surigao Del Norte')
129
- assert province == 'Surigao Del Norte'
130
-
131
- def test_province_with_invalid_name(self):
132
- with pytest.raises(ValueError):
133
- self.provider.province('InvalidProvince')
134
-
135
- def test_city_with_name(self):
136
- self.provider.region()
137
- self.provider.province()
138
- city = self.provider.city()
139
- if city:
140
- assert isinstance(city, str)
141
-
142
- def test_municipality_with_name(self):
143
- self.provider.region()
144
- self.provider.province()
145
- municipality = self.provider.municipality()
146
- if municipality:
147
- assert isinstance(municipality, str)
148
-
149
- def test_province_with_name_luzon(self):
150
- self.provider.region('luzon')
151
- province = self.provider.province('Ilocos Norte')
152
- assert province == 'Ilocos Norte'
153
-
154
- def test_province_with_name_visayas(self):
155
- self.provider.region('visayas')
156
- province = self.provider.province()
157
- assert isinstance(province, str) or province is None
158
-
159
- def test_province_with_name_mindanao(self):
160
- self.provider.region('mindanao')
161
- province = self.provider.province()
162
- assert isinstance(province, str) or province is None
163
-
164
- def test_municipality_with_invalid_name(self):
165
- self.provider.region()
166
- self.provider.province()
167
- with pytest.raises(ValueError):
168
- self.provider.municipality('InvalidMunicipality')
169
-
170
- def test_city_with_invalid_name(self):
171
- self.provider.region()
172
- self.provider.province()
173
- with pytest.raises(ValueError):
174
- self.provider.city('InvalidCity')
175
-
176
- def test_barangay_after_city(self):
177
- self.provider.region()
178
- self.provider.province()
179
- self.provider.city()
180
- barangay = self.provider.barangay()
181
- assert isinstance(barangay, str) or barangay is None
182
-
183
- def test_barangay_after_municipality(self):
184
- self.provider.region()
185
- self.provider.province()
186
- municipality = self.provider.municipality()
187
- if municipality:
188
- barangay = self.provider.barangay()
189
- assert isinstance(barangay, str) or barangay is None
190
-
191
- def test_full_address_with_no_city_or_municipality(self):
192
- address = self.provider.full_address()
193
- assert isinstance(address, str)
194
- assert len(address) > 0
195
-
196
- def test_region_different_island_groups(self):
197
- reg1 = self.provider.region('luzon')
198
- assert isinstance(reg1, str)
199
- reg2 = self.provider.region('visayas')
200
- assert isinstance(reg2, str)
201
- reg3 = self.provider.region('mindanao')
202
- assert isinstance(reg3, str)
203
-
204
- def test_province_resets_location(self):
205
- self.provider.region()
206
- self.provider.province()
207
- self.provider.city()
208
- self.provider.province()
209
- assert self.provider.current_location is None
210
- assert self.provider.current_location_type is None
211
-
212
- def test_email_no_personal_data(self):
213
- provider = ContactDataProvider(None)
214
- email = provider.email()
215
- assert isinstance(email, str)
216
- assert '@' in email
217
-
218
- class TestContactDataProvider:
219
- def setup_method(self):
220
- self.personal = PersonalDataProvider()
221
- self.provider = ContactDataProvider(self.personal)
222
-
223
- def test_mobile_generation(self):
224
- mobile = self.provider.mobile()
225
- assert isinstance(mobile, str)
226
- assert mobile.startswith('09')
227
-
228
- def test_mobile_generation_default(self):
229
- mobile = self.provider.mobile('default')
230
- assert isinstance(mobile, str)
231
- assert mobile.startswith('09')
232
-
233
- def test_mobile_international_format(self):
234
- mobile = self.provider.mobile('international')
235
- assert isinstance(mobile, str)
236
- assert mobile.startswith('+639')
237
-
238
- def test_mobile_invalid_format(self):
239
- mobile = self.provider.mobile('invalid')
240
- assert isinstance(mobile, str)
241
- assert mobile.startswith('09')
242
-
243
- def test_email_generation(self):
244
- email = self.provider.email()
245
- assert isinstance(email, str)
246
- assert '@' in email
247
-
248
- def test_email_with_custom_names(self):
249
- email = self.provider.email('John', 'Doe')
250
- assert isinstance(email, str)
251
- assert '@' in email
252
-
253
- def test_email_with_generated_names(self):
254
- self.personal.firstname()
255
- self.personal.lastname()
256
- email = self.provider.email()
257
- assert isinstance(email, str)
258
- assert '@' in email
File without changes
File without changes
File without changes