diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-05-27 20:23:30 -0400 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-05-27 20:23:30 -0400 |
| commit | e3f46a7a9222d951141ca6b6a932891ae7b20079 (patch) | |
| tree | 01ec3ebfbf9492198b07f8e280b6d8eca47cc03a /boot/test.py | |
| parent | d0c909dab1a06f5970216befd2cd0839327914fe (diff) | |
| parent | 5deb1799cefe9351b90d3457898990d454d4a4dc (diff) | |
| download | jasper-client-e3f46a7a9222d951141ca6b6a932891ae7b20079.tar.gz jasper-client-e3f46a7a9222d951141ca6b6a932891ae7b20079.zip | |
fixed merge conflicts
Diffstat (limited to 'boot/test.py')
| -rw-r--r-- | boot/test.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/boot/test.py b/boot/test.py new file mode 100644 index 0000000..c6bd3ff --- /dev/null +++ b/boot/test.py @@ -0,0 +1,42 @@ +import os +import sys +import unittest +from mock import patch +import vocabcompiler + +lib_path = os.path.abspath('../client') +mod_path = os.path.abspath('../client/modules/') + +sys.path.append(lib_path) +sys.path.append(mod_path) + +import g2p + + +class TestVocabCompiler(unittest.TestCase): + + def testWordExtraction(self): + sentences = "temp_sentences.txt" + dictionary = "temp_dictionary.dic" + languagemodel = "temp_languagemodel.lm" + + words = [ + 'HACKER', 'LIFE', 'FACEBOOK', 'THIRD', 'NO', 'JOKE', + 'NOTIFICATION', 'MEANING', 'TIME', 'TODAY', 'SECOND', + 'BIRTHDAY', 'KNOCK KNOCK', 'INBOX', 'OF', 'NEWS', 'YES', + 'TOMORROW', 'EMAIL', 'WEATHER', 'FIRST', 'MUSIC', 'SPOTIFY' + ] + + with patch.object(g2p, 'translateWords') as translateWords: + with patch.object(vocabcompiler, 'text2lm') as text2lm: + vocabcompiler.compile(sentences, dictionary, languagemodel) + + # 'words' is appended with ['MUSIC', 'SPOTIFY'] + # so must be > 2 to have received WORDS from modules + translateWords.assert_called_once_with(words) + self.assertTrue(text2lm.called) + os.remove(sentences) + os.remove(dictionary) + +if __name__ == '__main__': + unittest.main() |
