Example #1
0
 def test_cart_orm_db_setup_error(self):
     """call database_setup"""
     def fake_database_connect(cls):
         """throw error during connect"""
         cls.throw_error = True
         raise OperationalError('Failing')
     cart.cart_orm.CartBase.orig_database_connect = cart.cart_orm.CartBase.database_connect
     cart.cart_orm.CartBase.database_connect = \
         MethodType(fake_database_connect, cart.cart_orm.CartBase)
     cart.cart_orm.CartBase.throw_error = False
     with test_database(self.sqlite_db, (Cart, File), create_tables=False):
         database_setup(2)
     self.assertTrue(cart.cart_orm.CartBase.throw_error)
    def test_cart_orm_db_setup_error(self):
        """call database_setup"""

        def fake_database_connect(cls):
            """throw error during connect"""
            cls.throw_error = True
            raise OperationalError("Failing")

        cart.cart_orm.CartBase.orig_database_connect = cart.cart_orm.CartBase.database_connect
        cart.cart_orm.CartBase.database_connect = MethodType(fake_database_connect, cart.cart_orm.CartBase)
        cart.cart_orm.CartBase.throw_error = False
        with test_database(self.sqlite_db, (Cart, File), create_tables=False):
            database_setup(2)
        self.assertTrue(cart.cart_orm.CartBase.throw_error)
Example #3
0
def main():
    """Main function when running from the command line."""
    parser = ArgumentParser(description='Run the cart interface.')

    parser.add_argument('-p', '--port', metavar='PORT', type=int,
                        default=8080, dest='port',
                        help='port to listen on')
    parser.add_argument('-a', '--address', metavar='ADDRESS',
                        default='localhost', dest='address',
                        help='address to listen on')

    args = parser.parse_args()
    generator = CartGenerator()
    #make sure the database is up
    database_setup()
    srv = make_server(args.address, args.port,
                      generator.pacifica_cartinterface)

    srv.serve_forever()
Example #4
0
#!/usr/bin/python
"""
Pacifica Cart Interface
This is the main program that starts the WSGI server.
The core of the server code is in cart_interface.py.
"""
from argparse import ArgumentParser
from wsgiref.simple_server import make_server
from cart.cart_orm import database_setup
from cart.cart_interface import CartGenerator

PARSER = ArgumentParser(description='Run the cart interface.')

PARSER.add_argument('-p', '--port', metavar='PORT', type=int,
                    default=8080, dest='port',
                    help="port to listen on")
PARSER.add_argument('-a', '--address', metavar='ADDRESS',
                    default='localhost', dest='address',
                    help="address to listen on")

ARGS = PARSER.parse_args()
GENERATOR = CartGenerator()
#make sure the database is up
database_setup()
SRV = make_server(ARGS.address, ARGS.port,
                  GENERATOR.pacifica_cartinterface)

SRV.serve_forever()
 def test_cart_orm_db_setup(self):
     """call database_setup"""
     with test_database(self.sqlite_db, (Cart, File), create_tables=False):
         database_setup(2)
         self.assertTrue(Cart.table_exists())
         self.assertTrue(File.table_exists())
Example #6
0
def main():
    """Main function when running from the command line. Creates database"""
    database_setup()
Example #7
0
 def test_cart_orm_db_setup(self):
     """call database_setup"""
     with test_database(self.sqlite_db, (Cart, File), create_tables=False):
         database_setup(2)
         self.assertTrue(Cart.table_exists())
         self.assertTrue(File.table_exists())