Skip to content

Commit

Permalink
Add tests to repositories base
Browse files Browse the repository at this point in the history
  • Loading branch information
koldakov committed Dec 30, 2023
1 parent a2a1c23 commit 6c72497
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/repositories/tests/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from app.repositories.models import Character


class TestBase:
character = Character(id=1)

def test_to_dict_should_return_dict_with_id_when_id_provided(self):
assert self.character.to_dict() == {"id": 1}

def test_to_dict_should_return_empty_dict_when_id_provided_and_id_excluded(self):
assert self.character.to_dict(exclude=["id"]) == {}

def test_to_dict_should_not_return__sa_instance_state_in_dict_when_requested(self):
assert "_sa_instance_state" not in self.character.to_dict()

0 comments on commit 6c72497

Please sign in to comment.