Skip to content

Commit

Permalink
tests: add more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Julián Cortés committed Jul 6, 2020
1 parent f5601dc commit 0c21a3d
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pytest import mark

from nyoibo import Entity, fields


Expand All @@ -6,13 +8,29 @@ class TestEntity(Entity):
_value = fields.IntField()


def test_parse_str_value():
entity = TestEntity(name=10)
str_values = (
('10.5', '10.5'),
(10, '10'),
(15.2, '15.2')
)


@mark.parametrize('value, expected_result', str_values)
def test_parse_str_value(value, expected_result):
entity = TestEntity(name=value)

assert entity.name == expected_result


assert entity.name == '10'
int_values = (
('10', 10),
(10, 10),
(15.2, 15),
)


def test_parse_int_value():
entity = TestEntity(value='10')
@mark.parametrize('value, expected_result', int_values)
def test_parse_int_value(value, expected_result):
entity = TestEntity(value=value)

assert entity.value == 10
assert entity.value == expected_result

0 comments on commit 0c21a3d

Please sign in to comment.