diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-11 14:11:33 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-11 10:41:15 -0400 |
| commit | d7aee9421544aaff12fd4c26677085fd555d6728 (patch) | |
| tree | 649f18916fdcf4bda7c85cc37e4b49fb28efda3e /boot/test.py | |
| parent | 52a30cae6fb11ceedfaa9cb252432a2801a2de6f (diff) | |
| download | jasper-client-d7aee9421544aaff12fd4c26677085fd555d6728.tar.gz jasper-client-d7aee9421544aaff12fd4c26677085fd555d6728.zip | |
Added test for vocabcompiler to `--light` tests and updated travis config
Diffstat (limited to 'boot/test.py')
| -rwxr-xr-x | boot/test.py | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/boot/test.py b/boot/test.py deleted file mode 100755 index 638ca77..0000000 --- a/boot/test.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8-*- -import os - -if os.environ.get('JASPER_HOME') is None: - os.environ['JASPER_HOME'] = '/home/pi' - -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 UnorderedList(list): - - def __eq__(self, other): - return sorted(self) == sorted(other) - - -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(UnorderedList(words)) - self.assertTrue(text2lm.called) - os.remove(sentences) - os.remove(dictionary) - -if __name__ == '__main__': - unittest.main() |
