Add 68 tests, CI pipeline, and proprietary license

- 21 tests for LucidiaAI (sentiment, response, memory persistence)
- 40 tests for lucidia_logic (Trinary, psi_prime, breath functions, all symbolic math)
- 7 tests for substrate_performance_optimizer
- GitHub Actions CI with Python 3.10/3.11/3.12 matrix
- Replace MIT license with BlackRoad OS proprietary
- Add CI badge and Python badge to README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

RoadChain-SHA2048: 7ecced90454ac8af
RoadChain-Identity: alexa@sovereign
RoadChain-Full: 7ecced90454ac8af8796eba2e76e1c5a6325fe9f492446eb54b56c4967b8955222421e5b00932b26094a72046729c7d82ed51c60c71c2c47eec4215b89f18db8c4ec918630872f503511798b6233c352deb7caff00c3abf9d73939562db633a6ea4e47c46b3ff3be3822a8d94168be530ee2d3817a9f579b83bce735d43e1f579c7a5eae728824163cb4443ad00a93881c1915c87111c9ca130ae4f196a47ed68707b1ea4cab0d995ea546544cc83120a260f2e4f409b2a9d8a12603d0b4556c389caf25c906e58b982ff300dcc8a8425cc5f1e1e640c96602dd3ed5c88131f5fc790aa4a721d89a079db244a1c57297a4d56e9dbde75a8fc25539e15560213c
This commit is contained in:
2026-03-09 23:11:16 -05:00
parent f8c1919ed0
commit bedcb98b24
8 changed files with 455 additions and 16 deletions

129
tests/test_core.py Normal file
View File

@@ -0,0 +1,129 @@
"""Tests for lucidia.core — LucidiaAI conversational agent."""
import json
import os
import tempfile
import pytest
from lucidia.core import LucidiaAI
class TestSentimentAnalysis:
def test_positive_sentiment(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("I am so happy today") == 1
def test_negative_sentiment(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("I feel sad and awful") == -1
def test_neutral_sentiment(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("The weather is cloudy") == 0
def test_mixed_sentiment_positive_wins(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("happy great but sad") == 1
def test_mixed_sentiment_tie_is_neutral(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("happy but sad") == 0
def test_case_insensitive(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("I am HAPPY and EXCITED") == 1
def test_empty_string_neutral(self):
ai = LucidiaAI()
assert ai.analyze_sentiment("") == 0
def test_all_positive_words(self):
ai = LucidiaAI()
text = " ".join(LucidiaAI.POSITIVE_WORDS)
assert ai.analyze_sentiment(text) == 1
def test_all_negative_words(self):
ai = LucidiaAI()
text = " ".join(LucidiaAI.NEGATIVE_WORDS)
assert ai.analyze_sentiment(text) == -1
class TestGenerateResponse:
def test_positive_response(self):
ai = LucidiaAI()
resp = ai.generate_response("I had a great day!")
assert "wonderful" in resp.lower()
def test_negative_response(self):
ai = LucidiaAI()
resp = ai.generate_response("I feel terrible today")
assert "sorry" in resp.lower()
def test_neutral_response(self):
ai = LucidiaAI()
resp = ai.generate_response("The sky is blue")
assert "feel" in resp.lower()
def test_memory_callback(self):
ai = LucidiaAI()
ai.generate_response("First message")
resp = ai.generate_response("Second message")
assert "Earlier you talked about" in resp
def test_repeated_message(self):
ai = LucidiaAI()
ai.generate_response("same thing")
resp = ai.generate_response("same thing")
assert "mentioned that before" in resp
def test_adds_to_memory(self):
ai = LucidiaAI()
ai.generate_response("hello there")
assert len(ai.memory) == 1
assert ai.memory[0]["user"] == "hello there"
class TestMemory:
def test_add_to_memory(self):
ai = LucidiaAI()
ai.add_to_memory("hi", "hello")
assert len(ai.memory) == 1
assert ai.memory[0] == {"user": "hi", "lucidia": "hello"}
def test_save_and_load_memory(self):
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f:
path = f.name
try:
ai = LucidiaAI()
ai.add_to_memory("test input", "test response")
ai.save_memory(path)
ai2 = LucidiaAI(memory_file=path)
assert len(ai2.memory) == 1
assert ai2.memory[0]["user"] == "test input"
finally:
os.unlink(path)
def test_load_corrupt_file(self):
with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f:
f.write("not valid json{{{")
path = f.name
try:
ai = LucidiaAI(memory_file=path)
assert ai.memory == []
finally:
os.unlink(path)
def test_save_no_file_does_nothing(self):
ai = LucidiaAI()
ai.add_to_memory("a", "b")
ai.save_memory() # no file set, should not raise
def test_init_no_memory_file(self):
ai = LucidiaAI()
assert ai.memory == []
assert ai.memory_file is None
def test_init_nonexistent_file(self):
ai = LucidiaAI(memory_file="/tmp/nonexistent_lucidia_test.json")
assert ai.memory == []