from pydantic import BaseModel

from mosh import Pit


class Person(BaseModel):
    name: str
    age: int


def test_simple_mosh():

    bob = Person(name="Bob", age=25)
    alice = Person(name="Alice", age=30)

    pit = Pit("test_pit", object_types=[Person])
    pit.put(bob)
    pit.put(alice)

    results = pit.search(name="Alice")
    assert len(results) == 1
    result = results[0]
    assert result.name == "Alice"
