summaryrefslogtreecommitdiff
path: root/client/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'client/test.py')
-rw-r--r--client/test.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/client/test.py b/client/test.py
index a239b0d..a8f12be 100644
--- a/client/test.py
+++ b/client/test.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python2
# -*- coding: utf-8-*-
import os
+import sys
if os.environ.get('JASPER_HOME') is None:
os.environ['JASPER_HOME'] = '/home/pi'
@@ -9,11 +10,17 @@ import unittest
import argparse
from mock import patch
from urllib2 import URLError, urlopen
-import yaml
import test_mic
import g2p
import brain
+DEFAULT_PROFILE = {
+ 'prefers_email': False,
+ 'location': '08544',
+ 'timezone': 'US/Eastern',
+ 'phone_number': '012344321'
+}
+
def activeInternet():
try:
@@ -67,7 +74,7 @@ class TestG2P(unittest.TestCase):
class TestModules(unittest.TestCase):
def setUp(self):
- self.profile = yaml.safe_load(open("profile.yml", "r"))
+ self.profile = DEFAULT_PROFILE
self.send = False
def runConversation(self, query, inputs, module):
@@ -164,7 +171,7 @@ class TestBrain(unittest.TestCase):
@staticmethod
def _emptyBrain():
mic = test_mic.Mic([])
- profile = yaml.safe_load(open("profile.yml", "r"))
+ profile = DEFAULT_PROFILE
return brain.Brain(mic, profile)
@patch.object(brain, 'logError')
@@ -199,7 +206,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Test suite for the Jasper client code.')
parser.add_argument('--light', action='store_true',
- help="runs a subset of the tests (only requires Python dependencies)")
+ help='runs a subset of the tests (only requires Python dependencies)')
args = parser.parse_args()
test_cases = [TestBrain, TestModules]
@@ -212,4 +219,7 @@ if __name__ == '__main__':
for test_case in test_cases:
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(test_case))
- unittest.TextTestRunner(verbosity=2).run(suite)
+ result = unittest.TextTestRunner(verbosity=2).run(suite)
+
+ if not result.wasSuccessful():
+ sys.exit("Tests failed")