示例#1
0
    def run(self):
        try:
            from database import drop_all

            drop_all()
        except ImportError:
            print("Please, make sure database.drop_all exists in order to drop a db.")
示例#2
0
    def run(self):
        try:
            from database import drop_all

            drop_all()
        except ImportError:
            print("Please, make sure database.drop_all exists in order to drop a db.")
示例#3
0
    def tearDownClass(cls):
        from database import db, drop_all, remove_session

        drop_all()
        remove_session()

        db.engine.execute('DELETE FROM ...')  # Maybe some default datas ?
示例#4
0
    def setUpClass(cls):
        print ""
        print cls.__display__

        from main import app_factory
        from database import db, create_all, drop_all

        cls.app = app_factory(config.Testing)
        cls.client = cls.app.test_client()

        cls.app_key = 'testing'
        cls.api_token_admin = 'adminadmin'
        cls.api_token_member = 'membermember'
        cls.api_token_client = 'clientclient'

        drop_all()
        create_all()

        db.engine.execute('INSERT INTO `applications` (id, name, display, app_key, status) VALUES (1, "reflectiv", "Reflectiv", "testing", "DEV");')
        db.engine.execute('INSERT INTO `application_plans` (id, display, description, application_id, sms, members, storage, projects, monthly_price, yearly_price, currency, share) VALUES (1, "Free membership", "Free membership", 1, 0, 3, 0, 3, 0, 0, "USD", 50);')

        db.engine.execute('INSERT INTO `organizations` (name, display, currency, application_id, application_plan_id, created) VALUES ("reflectiv", "Reflectiv", "USD", 1, 1, "2014-04-01 00:00:00");')

        db.engine.execute('INSERT INTO `members` (id, display, organization_id, status, is_admin, is_disabled, lang) VALUES (1, "Administrator", 1, "MEMBER", 1, 0, "en"), (2, "Simple Member", 1, "MEMBER", 0, 0, "en"), (3, "Client", 1, "CLIENT", 0, 0, "en");')

        db.engine.execute('INSERT INTO `sessions` (expires, token, member_id) VALUES ("2015-12-31 00:00:00", "adminadmin", 1), ("2015-12-31 00:00:00", "membermember", 2), ("2015-12-31 00:00:00", "clientclient", 3);')
示例#5
0
 def test_show_available_products(self):
     """Test show_available_products function"""
     # Clear the database
     database.drop_all()
     expected_data = {
         'prd001': {
             'description': 'table',
             'product_type': 'diningroom',
             'quantity_available': '2'
         },
         'prd002': {
             'description': 'lamp',
             'product_type': 'office',
             'quantity_available': '3'
         },
         'prd003': {
             'description': 'desk',
             'product_type': 'office',
             'quantity_available': '1'
         },
         'prd005': {
             'description': 'shovel',
             'product_type': 'yard',
             'quantity_available': '5'
         }
     }
     database.import_data(PATH, 'products.csv', 'customers.csv',
                          'rentals.csv')
     return_dict = database.show_available_products()
     self.assertEqual(expected_data, return_dict)
     database.drop_all()
示例#6
0
 def test_import_data(self):
     """Test for import_data function from database.py"""
     client = MongoClient()
     db = client['database']
     self.assertEqual(((4, 4, 4), (0, 0, 0)),
                      import_data(db, '', 'products.csv', 'customers.csv',
                                  'rentals.csv'))
     drop_all(db)
示例#7
0
def db():
    """
    Initializes and returns a SQLAlchemy DB object
    """
    the_db.session.close()
    the_db.drop_all()
    the_db.create_all()
    return the_db
示例#8
0
 def test_show_available_products(self):
     """Test for show_available_products function from database.py"""
     client = MongoClient()
     db = client['database']
     product = db['product']
     add_data(product, 'products.csv')
     self.assertEqual(4, len(show_available_products(db)))
     test_result = show_available_products(db)
     self.assertTrue('9736' in test_result)
     self.assertTrue('6001' not in test_result)
     drop_all(db)
示例#9
0
文件: tests.py 项目: Invoicy/invoicy
    def setUpClass(cls):
        print ""
        print cls.__display__

        from main import app_factory
        from database import db, create_all, drop_all

        cls.app = app_factory(config.Testing)
        cls.client = cls.app.test_client()

        drop_all()
        create_all()
示例#10
0
 def test_add_data(self):
     """Test for add_data function from database.py"""
     client = MongoClient()
     db = client['database']
     product = db['product']
     customer = db['customer']
     rentals = db['rentals']
     self.assertEqual(0, add_data(product, 'products.csv'))
     self.assertEqual(0, add_data(customer, 'customers.csv'))
     self.assertEqual(0, add_data(rentals, 'rentals.csv'))
     self.assertEqual(['customer', 'rentals', 'product'],
                      db.list_collection_names())
     drop_all(db)
示例#11
0
    def setUpClass(cls):
        print("")
        print(cls.__display__)

        from main import app_factory
        from database import db, create_all, drop_all

        cls.app = app_factory(config.Testing)
        cls.client = cls.app.test_client()

        drop_all()
        create_all()

        db.engine.execute('INSERT INTO ...')  # Maybe some default datas ?
示例#12
0
 def test_show_rentals(self):
     """Test for show_rentals function from database.py"""
     client = MongoClient()
     db = client['database']
     customer = db['customer']
     rentals = db['rentals']
     add_data(customer, 'customers.csv')
     add_data(rentals, 'rentals.csv')
     test_result = show_rentals(db, '6921')
     self.assertTrue('AP987' in test_result)
     test_result2 = show_rentals(db, '2953')
     self.assertTrue('AP990' in test_result2)
     test_result3 = show_rentals(db, '0000')
     self.assertEqual(None, test_result3)
     drop_all(db)
示例#13
0
def initialize_markets(environment=None):
	"""
	Build up data from the csv files and initialize the markets 
	collection in the mongo database to match the csv files data
	
	(1). Clear markets collection in database
	(2). Build data
	(3). Insert data into markets collection
	"""
	db = database.connect(environment=environment)
	# (1)
	database.drop_all(db=db)
	# (2)
	data = build_data()
	# (3)
	db.markets.insert(data)
示例#14
0
    def test_import_data(self):
        """Test importing data into the database"""
        # Clear the database
        database.drop_all()

        # Test that file not found error works for all three conditions.
        test_one, test_two = database.import_data(PATH, 'empty_prod.csv',
                                                  'empty_cust.csv',
                                                  'empty_rental.csv')
        self.assertEqual(test_one, (0, 0, 0))
        self.assertEqual(test_two, (1, 1, 1))

        # Test that records are successfully added to the database with no errors.
        test_one, test_two = database.import_data(PATH, 'products.csv',
                                                  'customers.csv',
                                                  'rentals.csv')
        database.drop_all()
        self.assertEqual(test_one, (5, 10, 10))
        self.assertEqual(test_two, (0, 0, 0))
示例#15
0
 def test_show_rentals(self):
     """Test show_rentals function"""
     # Clear the database
     database.drop_all()
     expected_data = {
         'cust003': {
             'name': 'Kim',
             'address': '2132 Back St',
             'phone_number': '3432019212',
             'email': '*****@*****.**'
         },
         'cust008': {
             'name': 'Lisa',
             'address': '929 Court Rd',
             'phone_number': '7474738902',
             'email': '*****@*****.**'
         }
     }
     database.import_data(PATH, 'products.csv', 'customers.csv',
                          'rentals.csv')
     return_dict = database.show_rentals('prd001')
     self.assertEqual(expected_data, return_dict)
     database.drop_all()
示例#16
0
    def run(self):
        from database import drop_all

        drop_all()
示例#17
0
def drop_db(): # type: ignore
    db.session.commit()
    db.drop_all()
示例#18
0
    def run(self):
        from database import drop_all

        drop_all()
示例#19
0
def drop_all():
    db.drop_all()
    return json.dumps({'msg': 'Dropped all tables.'}), 200, json_content
示例#20
0
import requests
import json
from utils_func import simulate_tag
from PIL import Image
import yaml
import pytest
import database
import time
import io
import pandas as pd
from sqlalchemy import create_engine

# pulisco il db e lo tiro su
database.drop_all()
database.initialize_db()

getNewImageUrl = 'http://127.0.0.1:5000/get_new_image/{}'
postTagUrl = 'http://127.0.0.1:5000/post_tagged_crop'
cfg = yaml.load(open('config.yaml', 'r'), Loader=yaml.BaseLoader)
dburl = cfg['dburl']


@pytest.mark.parametrize(
    'userid',
    [1,2,10]
)
def test_get_new_image(userid, show=False):
    '''
    Test per verificare che a getNewImage si risponda con un crop 100x100 con un certo id nel filename
    '''
    r = requests.get(url=getNewImageUrl.format(userid))
示例#21
0
文件: tests.py 项目: Invoicy/invoicy
    def tearDownClass(cls):
        from database import db, drop_all, remove_session

        drop_all()
        remove_session()
示例#22
0
 def tearDown(self):
     from database import drop_all, remove_session
     drop_all()
     remove_session()
示例#23
0
 def run(self):
     drop_all()
     create_all()
     seed_all()
示例#24
0
 def teardown():
     # drop tables after finishing test cases
     drop_all()
示例#25
0
 def tearDown(self):
     from database import drop_all, remove_session
     drop_all()
     remove_session()
示例#26
0
 def run(self):
     drop_all()
示例#27
0
 def run(self):
     drop_all()
     create_all()
     seed_all()
示例#28
0
 def run(self):
     drop_all()
示例#29
0
def drop_tables():
    drop_all()