Exemplo n.º 1
0
 def test_get_title(self):
     aa = ElyxerEntry()
     self.assertEqual(aa.get_title(), None)
     aa.load(self.filename)
     self.assertEqual(aa.get_title(), 'Tutorial de LyX')
     self.assertRaises(TitleAlreadySetError,
                       lambda: aa.set_title('Second Title'))
Exemplo n.º 2
0
 def test_replace_special_characters(self):
     aa = ElyxerEntry()
     body = "<code>   SOME CODE   </code>"
     body += "Footnotes:  [→    →] "
     aa._Entry__body = body
     aa._Entry__replace_special_characters()
     self.assertTrue('<code>' in aa.get_body())
     self.assertTrue('</code>' in aa.get_body())
     self.assertTrue('→' not in aa.get_body())
Exemplo n.º 3
0
 def test_upload_entry(self):
     tt = Transmitter()
     tt.set_account(self.account_with_good_password)
     filename = 'test_files/entry_test'
     entry = ElyxerEntry()
     entry.set_transmitter(tt)
     entry.load(filename)
     entry.set_title('WoooYAH!')
     tt.publish_entry(entry)
Exemplo n.º 4
0
 def test_set_transmitter_exactly_once(self):
     tt = Transmitter()
     url = 'whee.com'
     username = '******'
     account = Account(url, username, None)
     tt.set_account(account)
     aa = ElyxerEntry()
     aa.set_transmitter(tt)
     self.assertRaises(TransmitterAlreadyExistsError,
                       lambda: aa.set_transmitter(tt))
Exemplo n.º 5
0
 def test_print_entry_summary(self):
     entry = ElyxerEntry()
     entry._Entry__images = [Image("<img src='photo.jpg' />")]
     entry._Entry__title = 'my title'
     entry._Entry__body = 'fine, fine day'
     returned = self.display.print_entry_summary(entry)
     expected = "You are about to publish:\n\n    my title\n      3 words\n      1 image\n"
     print '**************************************************************'
     print returned
     print expected
     self.assertEqual(returned, expected)
Exemplo n.º 6
0
 def start(self):
     self.__welcome()
     self.__entry = ElyxerEntry()
     self.__entry.load(self.__input_file)
     self.__ensure_title()
     self.__display_summary()
     account = self.__verify_which_account()
     self.__ensure_password(account)
     transmitter = self.__manager.pass_transmitter()
     self.__entry.set_transmitter(transmitter)
     self.__verify_create_new_or_overwrite()
     self.__publishing_message(account)
     self.__entry.publish()
     self.__closing_remarks()
Exemplo n.º 7
0
 def test_publish(self):
     aa = ElyxerEntry()
     self.assertRaises(TransmitterNotDefinedError, lambda: aa.publish())
Exemplo n.º 8
0
 def test_get_wordcount(self):
     aa = ElyxerEntry()
     aa.load(self.filename)
     returned = aa.get_num_words()
     self.assertTrue(isinstance(returned, int))
Exemplo n.º 9
0
 def test_load(self):
     aa = ElyxerEntry()
     aa.load(self.filename)
     self.assertTrue('Tutorial de LyX' in aa.get_body())
Exemplo n.º 10
0
 def test_get_num_images(self):
     aa = ElyxerEntry()
     self.assertEqual(aa.get_num_images(), 0)
     aa.load(self.filename)
     self.assertEqual(aa.get_num_images(), 1)
Exemplo n.º 11
0
 def test_get_num_words(self):
     aa = ElyxerEntry()
     aa._Entry__body = '<b> </b> three more lines'
     self.assertEqual(aa.get_num_words(), 3)