add a basic learn/retrieve test since I broke it a while back

This commit is contained in:
Brian S. Stephan 2023-02-19 17:56:26 -06:00
parent ed538d6045
commit 2399b5e882
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
1 changed files with 17 additions and 0 deletions

17
tests/test_markov_lib.py Normal file
View File

@ -0,0 +1,17 @@
"""Test markov utility methods."""
from django.test import TestCase
from markov.lib import get_word_out_of_states, learn_line
from markov.models import MarkovContext, MarkovState
class MarkovLibTestCase(TestCase):
"""Test library methods used by the Markov plugin."""
fixtures = ['tests/fixtures/irc_server_fixture.json', 'tests/fixtures/markov_fixture.json']
def test_learn_and_get(self):
"""Test that we can learn some lines and get a word back."""
learn_line("the elephant goes ERRRRRRRRRRRRR", MarkovContext.objects.get(pk=1))
word = get_word_out_of_states(MarkovState.objects.all())
self.assertIn(word, ['the', 'elephant', 'goes', 'ERRRRRRRRRRRRR', '__stop'])