summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-25 19:52:10 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-25 19:52:10 +0200
commit45713cef40a87d2e1eccd34c19e8d385d9dd0df4 (patch)
tree0186eaebb23ac49ac353e3eeeaa0dc54304d7504 /client
parent98e43796183c6fc681875e4b83c58a77d7fec544 (diff)
parentaa94000fb352d158d8968ee1c4ef169a2f16c175 (diff)
downloadjasper-client-45713cef40a87d2e1eccd34c19e8d385d9dd0df4.tar.gz
jasper-client-45713cef40a87d2e1eccd34c19e8d385d9dd0df4.zip
Merge pull request #197 from alexsiri7/test_fix
Fixed testWordExtraction not to depend on installed modules
Diffstat (limited to 'client')
-rw-r--r--client/test.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/client/test.py b/client/test.py
index 184a777..0ad37a3 100644
--- a/client/test.py
+++ b/client/test.py
@@ -4,7 +4,7 @@ import os
import sys
import unittest
import argparse
-from mock import patch
+from mock import patch, Mock
from urllib2 import URLError, urlopen
import test_mic
@@ -37,20 +37,23 @@ class TestVocabCompiler(unittest.TestCase):
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'
+ 'MUSIC', 'SPOTIFY'
]
+ mock_module = Mock()
+ mock_module.WORDS = [
+ 'MOCK'
+ ]
+
+ words.extend(mock_module.WORDS)
+
with patch.object(g2p, 'translateWords') as translateWords:
with patch.object(vocabcompiler, 'text2lm') as text2lm:
- vocabcompiler.compile(sentences, dictionary, languagemodel)
+ with patch.object(brain.Brain, 'get_modules', classmethod(lambda cls: [mock_module])) as modules:
+ 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)
+ translateWords.assert_called_once_with(UnorderedList(words))
+ self.assertTrue(text2lm.called)
os.remove(sentences)
os.remove(dictionary)