示例#1
0
 def setUp(self):
     service.init_db()
     db.drop_all()
     db.create_all()
     initial_data_1 = {
         'promo_name': 'Buy one get one free',
         'goods_name': 'Apple',
         'category': 'Fruit',
         'price': '2.99',
         'discount': '0.5',
         'available': False,
     }
     initial_data_2 = {
         'promo_name': '20% off',
         'goods_name': 'Carrot',
         'category': 'Vegetable',
         'price': '3.99',
         'discount': '0.8',
         'available': False,
     }
     initial_data_3 = {
         'promo_name': '70% off',
         'goods_name': 'IPhone XS',
         'category': 'Digital Products',
         'price': '1000.00',
         'discount': '0.7',
         'available': True,
     }
     self.save_promotion(initial_data_1)
     self.save_promotion(initial_data_2)
     self.save_promotion(initial_data_3)
     self.app = app.test_client()
示例#2
0
 def setUp(self):
     """ Runs before each test """
     service.init_db()
     db.drop_all()  # clean up the last tests
     db.create_all()  # create new tables
     Pet(name='fido', category='dog', available=True).save()
     Pet(name='kitty', category='cat', available=True).save()
     self.app = service.app.test_client()
 def setUp(self):
     """ Runs before each test """
     service.init_db()
     db.drop_all()  # clean up the last tests
     db.create_all()  # create new tables
     Shopcart(user_id=1, product_id=1, quantity=1, price=12.00).save()
     Shopcart(user_id=1, product_id=2, quantity=1, price=15.00).save()
     self.app = service.app.test_client()
示例#4
0
 def setUpClass(cls):
     """ Run once before all tests """
     service.app.debug = False
     service.initialize_logging(logging.INFO)
     # Set up the test database
     if DATABASE_URI:
         service.app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
     service.init_db()
示例#5
0
 def setUp(self):
     self.app = service.app.test_client()
     service.init_db()
     service.data_reset()
     service.data_load({
         "name": "fido",
         "category": "dog",
         "available": True
     })
     service.data_load({
         "name": "kitty",
         "category": "cat",
         "available": True
     })
示例#6
0
def before_all(context):
    """ Executed once before all tests """

    # TODO PhantomJS is deprecated - should try to use headless chrome in the future, but too much work for this project
    # from selenium.webdriver.chrome.options import Options
    # options = Options()
    # options.headless = True
    # driver = webdriver.Chrome(options=options)  # chromedriver needs to be in PATH for this to work
    # context.driver = driver

    context.driver = webdriver.PhantomJS()
    # context.driver.manage().timeouts().pageLoadTimeout(WAIT_SECONDS, TimeUnit.SECONDS);
    # context.driver.manage().timeouts().setScriptTimeout(WAIT_SECONDS, TimeUnit.SECONDS);
    context.driver.implicitly_wait(WAIT_SECONDS)  # seconds
    context.driver.set_window_size(1120, 550)
    context.base_url = BASE_URL
    # -- SET LOG LEVEL: behave --logging-level=ERROR ...
    # on behave command-line or in "behave.ini"
    context.config.setup_logging()
    service.init_db()
示例#7
0
"""
Promotions RESTFUL service
Starts the service and initializes logging
"""

import os
from app import app, service

# Pull options from environment
HOST = os.getenv('HOST', '0.0.0.0')
DEBUG = (os.getenv('DEBUG', 'False') == 'True')
PORT = os.getenv('PORT', '5000')

######################################################################
#   M A I N
######################################################################
if __name__ == "__main__":
    print("****************************************")
    print(" P R O M O T I O N S  S E R V I C E   R U N N I N G")
    print("****************************************")
    # server.init_db()
    # service.initialize_logging()
    service.init_db()
    app.run(host=HOST, port=int(PORT), debug=DEBUG)
示例#8
0
"""
Product Service Runner

Start the Product Service and initializes logging
"""

import os
from app import app, service

# Pull options from environment
DEBUG = (os.getenv('DEBUG', 'False') == 'True')
PORT = os.getenv('PORT', '5000')

######################################################################
#   M A I N
######################################################################
if __name__ == "__main__":
    print("****************************************")
    print(" P R O D U C T   S E R V I C E   R U N N I N G")
    print("****************************************")
    service.initialize_logging()
    service.init_db()  # make our sqlalchemy tables
    app.run(host='0.0.0.0', port=int(PORT), debug=DEBUG)
示例#9
0
 def setUp(self):
     """ Runs before each test """
     service.init_db()
     db.drop_all()  # clean up the last tests
     db.create_all()  # create new tables
     self.app = service.app.test_client()