コード例 #1
0
def database(app):
    with app.app_context():
        db.init_app(app)
        db.create_all()
        yield app
        db.session.close()
        db.drop_all()
コード例 #2
0
    def test_creating_bucketlist(self):
        """Tests successfully creating a bucketlist"""

        # this test would conflict with bucketlist defined in the setup
        # clear everythin before running it
        db.drop_all()
        db.create_all()

        # Instantiating a bucketlist object
        bucketlist = Bucketlist("Cook")
        # save the object to database
        db.session.add(bucketlist)
        db.session.commit()

        # asssert the attributes
        self.assertEqual(bucketlist.id, 1)
        self.assertEqual(bucketlist.name, "Cook")
        self.assertEqual(bucketlist.created_by, None)
        year = str(datetime.today().year)
        self.assertIn(year, str(bucketlist.date_created))
        self.assertIn(year, str(bucketlist.date_modified))
        self.assertEqual(len(bucketlist.items), 0)

        # test querying bucketlists
        bucketlist_query = Bucketlist.query.all()
        self.assertIn("<Bucketlist 'Cook'>", str(bucketlist_query))
        self.assertFalse("<Bucketlist 'Random'>" in str(bucketlist_query))
コード例 #3
0
    def test_creating_bucketlist_with_a_missing_name(self):
        """Tests successfully creating a bucketlist"""

        # this test would conflict with bucketlist defined in the setup
        # clear everythin before running it
        db.drop_all()
        db.create_all()

        with self.assertRaises(Exception) as context:

            # Instantiating a bucketlist object
            bucketlist = Bucketlist()
            # save the object to database
            db.session.add(bucketlist)
            db.session.commit()
            self.assertEqual('kjfdjkgf', 'nndnnv')
コード例 #4
0
def reset_db():
    db.drop_all()
    db.create_all()
コード例 #5
0
 def init_db():
     db.drop_all()
     db.create_all()
コード例 #6
0
ファイル: test_client.py プロジェクト: ralfeus/order
 def tearDown(self):
     db.session.remove()
     db.drop_all()
コード例 #7
0
ファイル: test_get_login.py プロジェクト: julozi/cavavin
 def tearDown(self):
     db.drop_all()