예제 #1
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.')
예제 #2
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.')
예제 #3
0
    def test_message_popup_create_texts(self, mock_popup):
        main = MainFrame()
        main.create_texts()
        message = 'Your files are located at:\n{}'.format(
            main.get_state()['save_directory'])
        mock_popup.assert_called_with('success', message,
                                      main.do_not_show_popup)

        main.do_not_show_popup.set(1)
        main.create_texts()
        self.assertEqual(mock_popup.call_count, 1)
예제 #4
0
    def test_create_text_error_pool_not_large_enough(self, mock_error):
        ConfigLoader()  # set up directories
        save_config({'paragraph_type': 'pool', 'probability_pronoun': 0})
        for file_name in (UNCOUNTABLE_NOUNS_CSV, COUNTABLE_NOUNS_CSV):
            with open(os.path.join(APP_FOLDER, file_name), 'w') as f:
                f.write('dog')
        main = MainFrame()

        main.create_texts()
        mock_error.assert_called_with(
            'Uh-oh!',
            'ValueError: pool size is too large for available nouns loaded from file'
        )
예제 #5
0
 def test_create_texts_reloads_words(self, mock_error):
     ConfigLoader()
     main = MainFrame()
     with open(os.path.join(APP_FOLDER, VERBS_CSV), 'w') as f:
         f.write('')
     main.create_texts()
     mock_error.assert_called_with(
         'Uh-oh!', 'ValueError: There are no verbs in the verb list.')
     self.assertFalse(
         os.path.exists(
             os.path.join(APP_FOLDER, DEFAULT_SAVE_DIR, '01_answer.pdf')))
     self.assertFalse(
         os.path.exists(
             os.path.join(APP_FOLDER, DEFAULT_SAVE_DIR, '01_error.pdf')))
예제 #6
0
    def test_create_texts_creates_files(self):
        prefix = 'adjjk409dvc'
        main = MainFrame()

        save_config({'file_prefix': prefix})
        main.load_config()

        main.do_not_show_popup.set(1)
        main.create_texts()
        self.assertTrue(
            os.path.exists(
                os.path.join(APP_FOLDER, DEFAULT_SAVE_DIR,
                             prefix + '01_answer.pdf')))
        self.assertTrue(
            os.path.exists(
                os.path.join(APP_FOLDER, DEFAULT_SAVE_DIR,
                             prefix + '01_error.pdf')))