Skip to content

Commit

Permalink
Repair game tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pykong committed Nov 23, 2023
1 parent 891ae09 commit 245ef6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion game/src/memory/threads/redis_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def _run_once(self) -> None:
if not self.queue.full() and not self.redis_empty():
for st in self.redis_random_transitions():
transition = deserialize_transition(st)
self.queue.put(transition)
self.queue.put(transition, block=False)
logger.debug(f"Added transition to queue: {transition}")

def redis_random_transitions(self) -> list[bytes]:
Expand Down
6 changes: 3 additions & 3 deletions game/test/memory/threads/test_redis_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def mock_redis_client():
# Create a test instance of RedisConsumerThread
@pytest.fixture(scope="function")
def consumer_thread(mock_redis_client):
queue = Queue(8)
queue = Queue(32)
redis_config = {"host": "localhost", "port": 6379}
consumer = RedisConsumerThread(redis_config, queue)
consumer.client = mock_redis_client
Expand All @@ -38,7 +38,7 @@ def test_run_once_adds_to_queue(consumer_thread, mock_redis_client):

# Then the item should be added to the queue
assert not consumer_thread.queue.empty()
actual = consumer_thread.queue.get()
actual = consumer_thread.queue.get_nowait()
assert_transitions_equal(transition, actual)


Expand All @@ -53,7 +53,7 @@ def test_run_once_skips_when_queue_is_full(consumer_thread, mock_redis_client):

# When Redis has one item
mock_redis_client.llen.return_value = 1
mock_redis_client.brpop.return_value = ("transitions", serialized_transition)
mock_redis_client.lindex.return_value = serialized_transition

# And _run_once is called
consumer_thread._run_once()
Expand Down

0 comments on commit 245ef6b

Please sign in to comment.