I'm working with python mockito in my unit test. I'm familiar with the abilities of mockito, such as verify, mock, capture, etc., but I wonder how to verify the value of the method's fileds.
My production code.
class Dog(BaseModel):
type: str
age: int
def bark(self, times: int) -> None:
print(f"{self.type} {self.age} {'ruf' * times}")
class FlowManager:
def __init__(self, barks: int, dog_type: str, age: int):
self.barks = barks
self.dog_type = dog_type
self.age = age
def foo(self):
# Some code....
dog = Dog(type=self.dog_type, age=self.age)
dog.bark(self.barks)
# More some code...
And this is the unit test that covers the "foo" method of the "FlowManager" class.
from mockito import verify, when
class TestFlowManager(unittest.TestCase):
def test_foo_happy_flow(self):
# Arrange
when(Dog).bark(...).thenReturn(None)
# Act
num_of_barks = 5
dog_type = "bulldog"
dog_age = 3
FlowManager(num_of_barks, dog_type, dog_age).foo()
# Assert
verify(Dog).bark(num_of_barks)
My question is: How could I assert the properties of the Dog object. In other words: how could I assert the Dog class created with dog_type=="bulldog" and dog_age==3?
Thanks!