Пример #1
0
    def test_reload_files(self):
        ConfigLoader()
        save_config({
            'probability_plural_noun': 0,
            'probability_negative_verb': 0,
            'probability_pronoun': 0
        })
        new_verb = Verb('boogahboogah').third_person()
        new_noun = Noun('wackawacka').definite()
        main = MainFrame()

        with open(os.path.join(APP_FOLDER, COUNTABLE_NOUNS_CSV), 'w') as f:
            f.write('wackawacka')
        with open(os.path.join(APP_FOLDER, UNCOUNTABLE_NOUNS_CSV), 'w') as f:
            f.write('')
        with open(os.path.join(APP_FOLDER, VERBS_CSV), 'w') as f:
            f.write('boogahboogah')

        paragraph = main.paragraph_generator.create_paragraph()
        for sentence in paragraph:
            self.assertNotIn(new_noun, sentence)
            self.assertNotIn(new_verb, sentence)

        main.reload_files()

        paragraph = main.paragraph_generator.create_paragraph()
        for sentence in paragraph:
            self.assertIn(new_noun, sentence)
            self.assertIn(new_verb, sentence)
Пример #2
0
 def test_create_text_error_no_verbs(self, mock_error):
     main = MainFrame()
     with open(os.path.join(APP_FOLDER, VERBS_CSV), 'w') as f:
         f.write('')
     main.reload_files()
     main.create_texts()
     mock_error.assert_called_with(
         'Uh-oh!', 'ValueError: There are no verbs in the verb list.')
Пример #3
0
 def test_reload_files_bad_verbs(self, mock_error):
     main = MainFrame()
     with open(os.path.join(APP_FOLDER, VERBS_CSV), 'w') as f:
         f.write('oh, no, this, is, very, very, bad')
     main.reload_files()
     mock_error.assert_called_with(
         'Bad file',
         'LoaderError: Bad values in columns for CSV for verbs. See default for example.'
     )
Пример #4
0
 def test_create_text_error_no_nouns(self, mock_error):
     main = MainFrame()
     for file_name in (UNCOUNTABLE_NOUNS_CSV, COUNTABLE_NOUNS_CSV):
         with open(os.path.join(APP_FOLDER, file_name), 'w') as f:
             f.write('')
     main.reload_files()
     main.create_texts()
     mock_error.assert_called_with(
         'Uh-oh!',
         'ValueError: There are no nouns in any of the nouns lists.')