Skip to content

Commit

Permalink
[feature/PI-346-bugs_and_helper_functions] fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaklinger committed May 22, 2024
1 parent 92cc772 commit 2c4f76c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/layers/domain/core/device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import defaultdict
from enum import StrEnum, auto
from itertools import chain
from typing import Any
from uuid import UUID, uuid4

from attr import dataclass, field
Expand Down Expand Up @@ -153,7 +154,7 @@ class Device(AggregateRoot):
questionnaire_responses: dict[str, list[QuestionnaireResponse]] = Field(
default_factory=lambda: defaultdict(list), exclude=True
)
indexes: set[tuple[str, str, str]] = Field(default_factory=set, exclude=True)
indexes: set[tuple[str, str, Any]] = Field(default_factory=set, exclude=True)

def update(self, **kwargs) -> DeviceUpdatedEvent:
device_data = self._update(data=kwargs)
Expand Down
8 changes: 3 additions & 5 deletions src/layers/domain/repository/device_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from event.json import json_loads

from .errors import ItemNotFound
from .keys import KEY_SEPARATOR, TableKeys, strip_key_prefix
from .keys import TableKeys, strip_key_prefix
from .marshall import marshall, marshall_value, unmarshall
from .repository import Repository
from .transaction import ConditionExpression, TransactionStatement, TransactItem
Expand Down Expand Up @@ -246,10 +246,8 @@ def read(self, id) -> Device:
keys = TableKeys.DEVICE_KEY.filter_and_group(items, key="sk")
_indexes = TableKeys.DEVICE_INDEX.filter(items, key="sk")
indexes = set(
(questionnaire_id, question, value)
for _, questionnaire_id, question, value in map(
lambda idx: idx["sk"].split(KEY_SEPARATOR), _indexes
)
(idx["questionnaire_id"], idx["question_name"], idx["value"])
for idx in _indexes
)

questionnaires = {}
Expand Down

0 comments on commit 2c4f76c

Please sign in to comment.