2014-06-30 22:58:10 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
2013-07-30 08:42:09 -05:00
|
|
|
import unittest
|
|
|
|
|
|
2014-06-11 15:06:22 +02:00
|
|
|
import bob
|
|
|
|
|
|
2014-02-21 14:44:25 +08:00
|
|
|
|
2013-07-30 08:42:09 -05:00
|
|
|
class BobTests(unittest.TestCase):
|
|
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_stating_something(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
'Whatever.',
|
2014-05-28 00:15:29 -01:00
|
|
|
bob.hey('Tom-ay-to, tom-aaaah-to.')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_shouting(self):
|
2013-07-30 08:42:09 -05:00
|
|
|
self.assertEqual(
|
2014-09-23 10:04:29 -05:00
|
|
|
'Whoa, chill out!',
|
2014-05-28 00:15:29 -01:00
|
|
|
bob.hey('WATCH OUT!')
|
2013-07-30 08:42:09 -05:00
|
|
|
)
|
|
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_asking_a_question(self):
|
2013-07-30 08:42:09 -05:00
|
|
|
self.assertEqual(
|
|
|
|
|
'Sure.',
|
2014-05-28 00:15:29 -01:00
|
|
|
bob.hey('Does this cryogenic chamber make me look fat?')
|
2013-07-30 08:42:09 -05:00
|
|
|
)
|
|
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_asking_a_numeric_question(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
'Sure.',
|
2014-05-28 00:15:29 -01:00
|
|
|
bob.hey('You are, what, like 15?')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_talking_forcefully(self):
|
2013-07-30 08:42:09 -05:00
|
|
|
self.assertEqual(
|
|
|
|
|
'Whatever.',
|
2014-05-28 00:15:29 -01:00
|
|
|
bob.hey("Let's go make out behind the gym!")
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_using_acronyms_in_regular_speech(self):
|
|
|
|
|
self.assertEqual(
|
2014-05-28 00:15:29 -01:00
|
|
|
'Whatever.', bob.hey("It's OK if you don't want to go to the DMV.")
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_forceful_questions(self):
|
|
|
|
|
self.assertEqual(
|
2014-09-23 10:04:29 -05:00
|
|
|
'Whoa, chill out!', bob.hey('WHAT THE HELL WERE YOU THINKING?')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_shouting_numbers(self):
|
|
|
|
|
self.assertEqual(
|
2014-09-23 10:04:29 -05:00
|
|
|
'Whoa, chill out!', bob.hey('1, 2, 3 GO!')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
2013-10-19 16:06:22 +02:00
|
|
|
def test_only_numbers(self):
|
|
|
|
|
self.assertEqual(
|
2014-05-28 00:15:29 -01:00
|
|
|
'Whatever.', bob.hey('1, 2, 3')
|
2013-10-19 16:06:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_question_with_only_numbers(self):
|
|
|
|
|
self.assertEqual(
|
2014-05-28 00:15:29 -01:00
|
|
|
'Sure.', bob.hey('4?')
|
2013-10-19 16:06:22 +02:00
|
|
|
)
|
|
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_shouting_with_special_characters(self):
|
|
|
|
|
self.assertEqual(
|
2014-09-23 10:04:29 -05:00
|
|
|
'Whoa, chill out!',
|
2014-05-28 00:15:29 -01:00
|
|
|
bob.hey('ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
2013-10-19 16:06:22 +02:00
|
|
|
def test_shouting_with_umlauts(self):
|
|
|
|
|
self.assertEqual(
|
2014-09-23 10:04:29 -05:00
|
|
|
'Whoa, chill out!', bob.hey('ÜMLÄÜTS!')
|
2013-10-19 16:06:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_calmly_speaking_with_umlauts(self):
|
|
|
|
|
self.assertEqual(
|
2014-06-30 22:58:10 +02:00
|
|
|
'Whatever.', bob.hey('ÜMLäÜTS!')
|
2013-10-19 16:06:22 +02:00
|
|
|
)
|
|
|
|
|
|
2013-08-19 10:15:51 -04:00
|
|
|
def test_shouting_with_no_exclamation_mark(self):
|
|
|
|
|
self.assertEqual(
|
2014-09-23 10:04:29 -05:00
|
|
|
'Whoa, chill out!', bob.hey('I HATE YOU')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_statement_containing_question_mark(self):
|
|
|
|
|
self.assertEqual(
|
2014-05-28 00:15:29 -01:00
|
|
|
'Whatever.', bob.hey('Ending with ? means a question.')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_prattling_on(self):
|
|
|
|
|
self.assertEqual(
|
2014-05-28 00:15:29 -01:00
|
|
|
'Sure.', bob.hey("Wait! Hang on. Are you going to be OK?")
|
2013-07-30 08:42:09 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_silence(self):
|
|
|
|
|
self.assertEqual(
|
2014-05-28 00:15:29 -01:00
|
|
|
'Fine. Be that way!', bob.hey('')
|
2013-08-19 10:15:51 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_prolonged_silence(self):
|
|
|
|
|
self.assertEqual(
|
2014-06-30 22:58:10 +02:00
|
|
|
'Fine. Be that way!', bob.hey(' \t')
|
2013-07-30 08:42:09 -05:00
|
|
|
)
|
2014-10-10 17:29:14 -04:00
|
|
|
|
2014-08-02 17:05:00 +12:00
|
|
|
def test_starts_with_whitespace(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
'Whatever.', bob.hey(' hmmmmmmm...')
|
|
|
|
|
)
|
2013-07-30 08:42:09 -05:00
|
|
|
|
2014-10-10 17:34:08 -04:00
|
|
|
def test_ends_with_whitespace(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
'Sure.', bob.hey('What if we end with whitespace? ')
|
|
|
|
|
)
|
|
|
|
|
|
2016-07-21 10:49:43 -07:00
|
|
|
def test_non_question_ends_with_whitespace(self):
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
'Whatever.', bob.hey('This is a statement with trailing whitespace ')
|
|
|
|
|
)
|
|
|
|
|
|
2013-07-30 08:42:09 -05:00
|
|
|
if __name__ == '__main__':
|
|
|
|
|
unittest.main()
|