Skip to content

Commit

Permalink
تحسين الإختبار لنوع النموذج
Browse files Browse the repository at this point in the history
  • Loading branch information
vzool committed Dec 11, 2024
1 parent 2b2d63f commit 538bbf8
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 11 deletions.
16 changes: 13 additions & 3 deletions README.ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<th>#</th>
<th>النموذج</th>
<th colspan="2">نوع قاعدة البيانات</th>
<th>المتطلبات</th>
<th>الحالة</th>
</tr>
<tr>
Expand All @@ -50,13 +51,15 @@
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>DictModel</td>
<td></td>
<td>Camel</td>
<td>جاري العمل عليه</td>
<td>-</td>
<td>مكتمل</td>
</tr>
<tr>
<td></td>
Expand All @@ -70,31 +73,37 @@
<td rowspan="6">SQLModel</td>
<td>1</td>
<td>SQLite</td>
<td>جاري العمل عليه</td>
<td>-</td>
<td>مكتمل</td>
</tr>
<tr>
<td>2</td>
<td>MySQL</td>
<td>بالخطة</td>
<td><a href="https://pypi.org/project/PyMySQL/">pymysql</a></td>
<td>جاري العمل عليه</td>
</tr>
<tr>
<td>3</td>
<td>MariaDB</td>
<td>-</td>
<td>بالخطة</td>
</tr>
<tr>
<td>4</td>
<td>PostgreSQL</td>
<td>-</td>
<td>بالخطة</td>
</tr>
<tr>
<td>5</td>
<td>CockroachDB</td>
<td>-</td>
<td>بالخطة</td>
</tr>
<tr>
<td>6</td>
<td>Oracle</td>
<td>-</td>
<td>بالخطة</td>
</tr>
<tr>
Expand All @@ -103,6 +112,7 @@
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>

Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca
<th>#</th>
<th>Model</th>
<th colspan="2">Database Engine</th>
<th>Requirements</th>
<th>Status</th>
</tr>
<tr>
Expand All @@ -46,51 +47,60 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>1</td>
<td>DictModel</td>
<td></td>
<td>Camel</td>
<td>In Progress</td>
<td>-</td>
<td>Done</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td rowspan="6">2</td>
<td rowspan="6">SQLModel</td>
<td>1</td>
<td>SQLite</td>
<td>In Progress</td>
<td>-</td>
<td>Done</td>
</tr>
<tr>
<td>2</td>
<td>MySQL</td>
<td>Planned</td>
<td><a href="https://pypi.org/project/PyMySQL/">pymysql</a></td>
<td>In Progress</td>
</tr>
<tr>
<td>3</td>
<td>MariaDB</td>
<td>-</td>
<td>Planned</td>
</tr>
<tr>
<td>4</td>
<td>PostgreSQL</td>
<td>-</td>
<td>Planned</td>
</tr>
<tr>
<td>5</td>
<td>CockroachDB</td>
<td>-</td>
<td>Planned</td>
</tr>
<tr>
<td>6</td>
<td>Oracle</td>
<td>-</td>
<td>Planned</td>
</tr>
<tr>
Expand All @@ -99,6 +109,7 @@ Zakat is a user-friendly Python library designed to simplify the tracking and ca
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>

Expand Down
10 changes: 9 additions & 1 deletion tests/test_00_zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@


def test_zakat_tracker():
zakat.test(debug=True)
zakat.test(
debug=True,
dict_model=True,
sqlite_model=True,
mysql_model=False,
mariadb_model=False,
postgresql_model=False,
cockroachdb_model=False,
)
27 changes: 23 additions & 4 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,7 @@ def __init__(self, db_path: str = "./zakat_db/zakat.camel"):
self._vault = None
self.reset()
self.path(db_path)
self.provider = 'dict'

def path(self, path: str = None) -> str:
if path is None:
Expand Down Expand Up @@ -2704,8 +2705,9 @@ def __init__(self, **db_params):
self.debug = False
self._file_exists = False
self.raw_sql = True
self.provider = str.lower(db_params['provider'])

if str.lower(db_params['provider']) == 'sqlite' and 'filename' in db_params:
if self.provider == 'sqlite' and 'filename' in db_params:
db_params['filename'] = str(self.path(db_params['filename']))
self._db_path = db_params['filename']
self._file_exists = True
Expand Down Expand Up @@ -5045,8 +5047,8 @@ def test(
debug: bool = False,
dict_model: bool = True,
sqlite_model: bool = True,
mariadb_model: bool = False,
mysql_model: bool = False,
mariadb_model: bool = False,
postgresql_model: bool = False,
cockroachdb_model: bool = False,
) -> None:
Expand All @@ -5062,8 +5064,8 @@ def test(
debug: If True, enables detailed logging and output during the test process.
dict_model: If True, tests the in-memory dictionary model.
sqlite_model: If True, tests the SQLite model.
mariadb_model: If True, tests the MariaDB model.
mysql_model: If True, tests the MySQL model.
mariadb_model: If True, tests the MariaDB model.
postgresql_model: If True, tests the PostgreSQL model.
cockroachdb_model: If True, tests the CockroachDB model.
Expand Down Expand Up @@ -5095,12 +5097,29 @@ def test(
debug=True,
),
)
if mysql_model:
models.append(
SQLModel(
provider='mysql',
host='127.0.0.1',
user='root',
passwd='t00r',
db='zakat',
debug=True,
),
)
if mariadb_model:
pass
if postgresql_model:
pass
if cockroachdb_model:
pass
for model in models:
start = time_ns()
assert model.test(debug=debug)
ledger = ZakatTracker(model=model)
assert ledger.test(debug=debug)
durations[model.__class__.__name__] = time_ns() - start
durations[f'{model.__class__.__name__}({model.provider})'] = time_ns() - start
if debug:
print("#########################")
print("######## TEST DONE ########")
Expand Down

0 comments on commit 538bbf8

Please sign in to comment.