Issue 150 - Add unit tests
parent
740f35fa60
commit
c7f1c81e37
|
@ -171,9 +171,9 @@ class WolframAlphaSkill(MycroftSkill):
|
|||
if "|" in result: # Assuming "|" indicates a list of items
|
||||
verb = ":"
|
||||
|
||||
result = self.__process_wolfram_string(result)
|
||||
result = self.process_wolfram_string(result)
|
||||
input_interpretation = \
|
||||
self.__process_wolfram_string(input_interpretation)
|
||||
self.process_wolfram_string(input_interpretation)
|
||||
response = "%s %s %s" % (input_interpretation, verb, result)
|
||||
|
||||
self.speak(response)
|
||||
|
@ -188,7 +188,7 @@ class WolframAlphaSkill(MycroftSkill):
|
|||
return None
|
||||
|
||||
@staticmethod
|
||||
def __process_wolfram_string(text):
|
||||
def process_wolfram_string(text):
|
||||
# Remove extra whitespace
|
||||
text = re.sub(r" \s+", r" ", text)
|
||||
|
||||
|
@ -196,7 +196,7 @@ class WolframAlphaSkill(MycroftSkill):
|
|||
text = re.sub(r" \| ", r", ", text)
|
||||
|
||||
# Convert newlines to commas
|
||||
text = re.sub(r"\n", r",. ", text)
|
||||
text = re.sub(r"\n", r", ", text)
|
||||
|
||||
# Convert !s to factorial
|
||||
text = re.sub(r"!", r",factorial", text)
|
||||
|
|
|
@ -48,3 +48,19 @@ class WolframAlphaTest(unittest.TestCase):
|
|||
def test_invalid_pod(self):
|
||||
res = self.create_result("InvalidTitle", "Test")
|
||||
self.assertEquals(WolframAlphaSkill().get_result(res), None)
|
||||
|
||||
def test_whitespace_process(self):
|
||||
self.assertEquals(WolframAlphaSkill().process_wolfram_string
|
||||
("Test string"), "Test string")
|
||||
|
||||
def test_pipe_process(self):
|
||||
self.assertEquals(WolframAlphaSkill().process_wolfram_string
|
||||
("Test | string"), "Test, string")
|
||||
|
||||
def test_newline_process(self):
|
||||
self.assertEquals(WolframAlphaSkill().process_wolfram_string
|
||||
("Test\nstring"), "Test, string")
|
||||
|
||||
def test_factorial_process(self):
|
||||
self.assertEquals(WolframAlphaSkill().process_wolfram_string
|
||||
("Test!"), "Test,factorial")
|
||||
|
|
Loading…
Reference in New Issue