mirror of
https://github.com/enpaul/peewee-plus.git
synced 2024-11-14 10:36:51 +00:00
Ethan Paul
480e3f3875
Add tests for __all__ public api definition Rename test modules for consistency
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# pylint: disable=unused-import
|
|
# pylint: disable=redefined-outer-name
|
|
# pylint: disable=missing-class-docstring
|
|
# pylint: disable=too-few-public-methods
|
|
import peewee
|
|
|
|
import peewee_plus
|
|
from .fixtures import fakedb
|
|
|
|
|
|
def test_public_api():
|
|
"""Test that the public API components are exposed via ``__all__``"""
|
|
|
|
assert peewee_plus.PrecisionFloatField.__name__ in peewee_plus.__all__
|
|
|
|
|
|
# There isn't anything we can really test here since this field implements
|
|
# a MySQL-specific syntax and we test with SQLite. This test is here just
|
|
# to ensure that the behavior is consistent with the normal FloatField when
|
|
# working with an unsupported database backend
|
|
def test_compatibility(fakedb):
|
|
"""Check that the precision float field works on sqlite"""
|
|
|
|
class TestModel(peewee.Model):
|
|
class Meta:
|
|
database = fakedb
|
|
|
|
precise = peewee_plus.PrecisionFloatField(max_digits=7, decimal_places=3)
|
|
imprecise = peewee.FloatField()
|
|
|
|
fakedb.create_tables([TestModel])
|
|
|
|
model = TestModel(precise=1234.567, imprecise=1234.567)
|
|
model.save()
|
|
|
|
model = TestModel.get()
|
|
assert model.precise == model.imprecise
|