class Test(unittest.TestCase):
    def setUp(self):
        self.header_wrapper = 'h1'
        self.vesna = VesnaGenerator(entry_options={'header_wrapper': self.header_wrapper})

    def test_generate_entry(self):
        entry = self.vesna.generate_entry()
        self.assertNotEqual(entry.title, "")
        self.assertNotEqual(entry.body, "")
        self.assertNotEqual(entry.header, "")

    def test_get_method_for_slug(self):
        entry = self.vesna.generate_entry()
        self.assertNotEqual(entry['slug'], "")

    def test_header_wrapper(self):
        entry = self.vesna.generate_entry()
        self.assertTrue(self.header_wrapper in entry.header)
Esempio n. 2
0
 def handle(self, *args, **options):
     vesna = VesnaGenerator()
     n = 100
     pbar = ProgressBar(maxval=n).start()
     for i in range(n):
         entry = vesna.generate_entry()
         Post(
             title=entry.title,
             content=entry.body,
             slug=entry.slug,
             datetime=datetime.now()
         ).save()
         pbar.update(i+1)
     pbar.finish()