Beispiel #1
0
 def run(self, **kwargs):
     input_var = input(
         'Are you sure you wish to create fake data? y/n: ')
     if input_var == 'y' or input_var == 'Y':
         fdc = FakeDataFactory(db)
         fdc.generate_data(**kwargs)
         fdc.db.session.commit()
         fdc.increment_sequence_ids()
         print('Fake data created')
Beispiel #2
0
 def setUp(self):
     db.create_all()
     self.datafactory = FakeDataFactory(1234)
Beispiel #3
0
class FactoryTest(MainTestCase):

    def setUp(self):
        db.create_all()
        self.datafactory = FakeDataFactory(1234)

    def tearDown(self):
        db.session.remove()
        db.drop_all()

    def test_authorfactory(self):
        author = AuthorFactory()
        self.assertIsInstance(author, Author)
        self.assertIsNotNone(author.id)
        self.assertIsNotNone(author.name)
        self.assertIsNotNone(author.givenname)
        self.assertIsNotNone(author.familyname)
        self.assertIsNotNone(author.url)
        self.assertIsNotNone(author.email)

        author2 = AuthorFactory()
        self.assertNotEqual(author.id, author2.id)

    def test_userfactory(self):
        user = UserFactory()
        self.assertIsInstance(user, User)
        self.assertIsNotNone(user.id)
        self.assertIsNotNone(user.email)
        self.assertIsNotNone(user.active)

    def test_entryfactory(self):
        entry = EntryFactory()
        self.assertIsInstance(entry, Entry)
        self.assertIsNotNone(entry.id)
        self.assertIsNotNone(entry.title)
        self.assertIsNotNone(entry.guid)
        self.assertIsNotNone(entry.content)
        self.assertIsInstance(entry.published, datetime)

    def test_subscriptionfactory(self):
        sub = SubscriptionFactory()
        self.assertIsInstance(sub, Subscription)
        self.assertIsNotNone(sub.user_id)
        self.assertIsNotNone(sub.author_id)
        self.assertIsNotNone(sub.active)
        self.assertIsInstance(sub.created_on, datetime)

    def test_feedfactory(self):
        feed = FeedFactory()
        self.assertIsInstance(feed, Feed)
        self.assertIsNotNone(feed.id)
        self.assertIsNotNone(feed.topic)
        self.assertIsNotNone(feed.hub)
        self.assertIsNotNone(feed.title)
        self.assertLess(len(feed.description), 501)
        self.assertIsNotNone(feed.lease_seconds)
        self.assertIsNotNone(feed.sub_time)
        self.assertIsNotNone(feed.unique_url)
        self.assertIsNotNone(feed.secret)
        self.assertIsNotNone(feed.status)

    def test_datafactory_creates_users(self):
        users = self.datafactory.create_users(10)
        self.assertEqual(len(users), 10)

    def test_datafactory_creates_feeds(self):
        feeds = self.datafactory.create_feeds(10)
        self.assertEqual(len(feeds), 10)

    def test_datafactory_creates_authors(self):
        authors = self.datafactory.create_authors(10)
        self.assertEqual(len(authors), 10)

    def test_datafactory_creates_entries(self):
        entries = self.datafactory.create_entries(10)
        self.assertEqual(len(entries), 10)

    def test_datafactory_creates_subscriptions(self):
        users = self.datafactory.create_users(2)
        authors = self.datafactory.create_authors(10)
        subs = self.datafactory.create_subscriptions(users, authors, 20, 5)
        self.assertGreater(len(subs), 0)
        self.assertIsNotNone(users[0].subscriptions)