mirror of
https://github.com/lightbroker/llmsecops-research.git
synced 2026-02-13 15:12:51 +00:00
31 lines
993 B
Python
31 lines
993 B
Python
import logging
|
|
import pytest
|
|
|
|
from src.text_generation.services.logging.file_logging_service import FileLoggingService
|
|
from src.text_generation.services.nlp.fake_text_generation_completion_service import FakeTextGenerationCompletionService
|
|
|
|
|
|
def test_file_logging_service_has_filehandler():
|
|
logfile = 'test.log'
|
|
svc = FileLoggingService(filename=logfile)
|
|
assert svc.logger.hasHandlers() == True
|
|
assert any(type(handler) == logging.FileHandler for handler in svc.logger.handlers)
|
|
|
|
|
|
def test_language_model_response_service_valid_input():
|
|
svc = FakeTextGenerationCompletionService()
|
|
response = svc.invoke('what is 1 + 1?')
|
|
assert response != None
|
|
assert response != ''
|
|
|
|
|
|
def test_language_model_response_service_empty_input():
|
|
svc = FakeTextGenerationCompletionService()
|
|
|
|
with pytest.raises(ValueError):
|
|
_ = svc.invoke(user_prompt='')
|
|
|
|
with pytest.raises(ValueError):
|
|
user_prompt = None
|
|
_ = svc.invoke(user_prompt=user_prompt)
|