예제 #1
0
def test_find_word(context1):
    finder = WordFinder(context1)

    options = finder.find_slice(0, 16)
    assert options
    assert len(options) == 2
    assert options[0].word == '......-...-..---'
    assert options[1].word == '......-...-..'
예제 #2
0
def test_find_word_2(context2):
    finder = WordFinder(context2)

    options = finder.find_slice(0, 2)
    assert len(options) == 1
    assert options[0].word == '-'

    options = finder.find_slice(1, 1)
    assert len(options) == 1
    assert options[0].word == '-'
예제 #3
0
def context1():
    context = Context()
    context.add_sentence('......-...-..---')  # HELLO
    context.add_alphabet(MorseAlphabet())

    encoder = WordEncoder(context)
    context.add_word_encoder(encoder)
    encoder.add_word('HELLO')

    context.add_word_finder(WordFinder(context))

    return context
예제 #4
0
 def test_apple(self):
     apples = WordFinder.find_word("apple")
     self.assertIn("The wood of the apple tree.", apples)
예제 #5
0
 def setUp(self):
     WordFinder.read_file()
예제 #6
0
 def test_texas_mixed(self):
     texas = WordFinder.find_word("tExAs")
     self.assertIn(
         "The 28th state of the United States of America, "
         "located in the southern US.",
         texas)
예제 #7
0
 def test_nonexisting_word(self):
     match = WordFinder.find_word("asdsadasdsadadadasd")
     self.assertEqual("The word doesn't exist", match)
예제 #8
0
 def test_nonexisting_apples(self, input):
     apples = WordFinder.find_word("apples")
     self.assertEqual("The word doesn't exist", apples)