<commit_before>#!/usr/bin/env python3
# This is free and unencumbered software released into the public domain.

"""Test cases for the conreality.sdk.messaging module."""

from conreality.sdk.messaging import *
from conreality.sdk.storage import DataDirectory
from inspect import *
import os

class TestTopicRegistry:
  """Test cases for the conreality.sdk.messaging.TopicRegistry class."""

  def test_construction_from_path(self):
    registry = TopicRegistry(path='/tmp')
    assert registry.path == '/tmp'

  def test_topics_generator(self):
    registry = TopicRegistry(path='/tmp')
    assert isgenerator(registry.topics())

class TestTopic:
  """Test cases for the conreality.sdk.messaging.Topic class."""

  def test_construction_from_path(self):
    topic = Topic(path='/tmp/foobar')
    assert topic.name == 'foobar'
    assert topic.path == '/tmp/foobar'
    assert topic.mode == 'r+'

  def test_construction_from_name(self):
    topic = Topic(name='foobar')
    assert topic.name == 'foobar'
    assert topic.path == os.path.join(DataDirectory.BASE_PATH, 'topics', 'foobar')
    assert topic.mode == 'r+'

class TestPublisher:
  """Test cases for the conreality.sdk.messaging.Publisher class."""
<commit_msg>Enhanced conreality.sdk.messaging tests using tmpdir fixtures.<commit_after>#!/usr/bin/env python3
# This is free and unencumbered software released into the public domain.

"""Test cases for the conreality.sdk.messaging module."""

from conreality.sdk.messaging import *
from conreality.sdk.storage import DataDirectory
from inspect import *
import os

class TestTopicRegistry:
  """Test cases for the conreality.sdk.messaging.TopicRegistry class."""

  def test_construction_from_path(self, tmpdir):
    registry = TopicRegistry(path=str(tmpdir))
    assert registry.path == str(tmpdir)

  def test_topics_generator(self, tmpdir):
    registry = TopicRegistry(path=str(tmpdir))
    assert isgenerator(registry.topics())

class TestTopic:
  """Test cases for the conreality.sdk.messaging.Topic class."""

  def test_construction_from_path(self, tmpdir):
    topic = Topic(path=str(tmpdir.join('foobar')))
    assert topic.name == 'foobar'
    assert topic.path == os.path.join(str(tmpdir), 'foobar')
    assert topic.mode == 'r+'

  def test_construction_from_name(self, tmpdir):
    DataDirectory.BASE_PATH = str(tmpdir)
    topic = Topic(name='foobar')
    assert topic.name == 'foobar'
    assert topic.path == os.path.join(DataDirectory.BASE_PATH, 'topics', 'foobar')
    assert topic.mode == 'r+'

  def test_subscribers_generator(self):
    topic = Topic(name='foobar')
    assert isgenerator(topic.subscribers())

class TestPublisher:
  """Test cases for the conreality.sdk.messaging.Publisher class."""

{'fraction_non_alphanumeric': 0.12221002561287962, 'fraction_numerical': 0.0007317965605561653, 'mean_word_length': 4.683991683991684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5291639', 'n_tokens_mistral': 883, 'n_tokens_neox': 840, 'n_words': 210}