Skip to content

Commit

Permalink
Fix tests...
Browse files Browse the repository at this point in the history
  • Loading branch information
originalsouth committed Dec 24, 2024
1 parent ee92430 commit 358ec81
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions octopoes/nibbles/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def __init__(
self.cache: dict[OOI, dict[str, dict[tuple[Any, ...], set[OOI]]]] = {}
self.nibble_repository = nibble_repository
self.nibbles: dict[str, NibbleDefinition] = get_nibble_definitions()
inis = [nibble._ini() for nibble in self.nibbles.values()]
nibble_repository.put_many(inis, datetime.now())

def __del__(self):
self._write(datetime.now())
Expand Down Expand Up @@ -109,6 +107,10 @@ def checksum_nibbles(self) -> dict[str, str | None]:
def disable(self):
self.nibbles = {}

def register(self):
inis = [nibble._ini() for nibble in self.nibbles.values()]
self.nibble_repository.put_many(inis, datetime.now())

def retrieve(self, nibble_id: str, valid_time: datetime) -> list[list[Any]]:
nibble = self.nibbles[nibble_id]
if len(nibble.signature) > 1:
Expand Down
3 changes: 3 additions & 0 deletions octopoes/octopoes/repositories/nibble_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ def put_many(self, inis: list[dict[str, Any]], valid_time: datetime):
def history(self, nibble: str, with_docs: bool = False) -> list[TransactionRecord]:
return self.session.client.get_entity_history(self._xtid(nibble), with_docs=with_docs)

def status(self):
return self.session.client.status()

def commit(self):
self.session.commit()
2 changes: 1 addition & 1 deletion octopoes/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def xtdb_scan_profile_repository(xtdb_session: XTDBSession, event_manager) -> It


@pytest.fixture
def xtdb_nibble_repository(xtdb_session: XTDBSession, event_manager) -> Iterator[XTDBNibbleRepository]:
def xtdb_nibble_repository(xtdb_session: XTDBSession) -> Iterator[XTDBNibbleRepository]:
yield XTDBNibbleRepository(xtdb_session)


Expand Down
1 change: 1 addition & 0 deletions octopoes/tests/integration/test_nibbles.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def test_nibbles_update(xtdb_octopoes_service: OctopoesService, event_manager: M


def test_nibble_states(xtdb_octopoes_service: OctopoesService, event_manager: Mock, valid_time: datetime):
xtdb_octopoes_service.nibbler.register()
assert len(xtdb_octopoes_service.nibbler.nibble_repository.get_all(valid_time)) == len(
xtdb_octopoes_service.nibbler.nibbles
)

0 comments on commit 358ec81

Please sign in to comment.