Exemple #1
0
    def setUp(self, populate=True):
        # Load testing configuration
        application.config.from_object('config.TestingConfig')
        self.app = application.test_client()
        db.create_all()

        # Initialize the request context
        self.context = application.test_request_context()
        self.context.push()

        # load data
        if (populate):
            self.populate()
Exemple #2
0
    def setUp(self):
        app.config["TEST_DBNAME"] = "ui_test"
        try:
            app.mongo = PyMongo(app, config_prefix="TEST")
        except:
            pass

        self.client = app.test_client()
        num_trees, height = (5, 5)
        self.row = pb.TrainingRow(
            forestConfig=fake_data.fake_config(num_trees), forest=fake_data.fake_forest(height, num_trees)
        )

        with app.test_request_context():
            self._id = str(app.mongo.db.decisiontrees.insert(protobuf_to_dict(self.row)))
Exemple #3
0
    def setUp(self):
        app.config['TEST_DBNAME'] = 'ui_test'
        try:
            app.mongo = PyMongo(app, config_prefix='TEST')
        except:
            pass

        self.client = app.test_client()
        num_trees, height = (5, 5)
        self.row = pb.TrainingRow(
            forestConfig=fake_data.fake_config(num_trees),
            forest=fake_data.fake_forest(height, num_trees),
        )

        with app.test_request_context():
            self._id = str(
                app.mongo.db.decisiontrees.insert(protobuf_to_dict(self.row)))
Exemple #4
0
        def decorated(*args, **kwargs):
            ctx = None
            if not has_request_context():
                # HACKY HACK HACK
                # this allows the stuff to work from command line, it is
                # kind of terrible though. Ideally we just use current_app
                from app import application
                environ_overrides = {'HTTP_HOST': config.MAIL_URL_ROOT}
                ctx = application.test_request_context(
                        environ_overrides=environ_overrides)
                ctx.push()

            ret = f(*args, **kwargs)

            if ctx:
                ctx.pop()
            return ret
Exemple #5
0
 def send_dogfood(cls, msg, deferred=False):
     msg.subject = "[%s] %s" % (msg.recipients[0], msg.subject)
     old_recipients = msg.recipients
     old_sender = msg.sender
     msg.recipients = ['*****@*****.**']
     msg.sender = '*****@*****.**'
     if deferred:
         cls.enqueue(msg)
     else:
         from app import application
         from app.lib.internal_mailer import InternalMailer
         ctx = None
         if not has_request_context():
             environ_overrides = {'HTTP_HOST': config.MAIL_URL_ROOT}
             ctx = application.test_request_context(
                 environ_overrides=environ_overrides)
             ctx.push()
         mailer = InternalMailer.mailer(application)
         mailer.send(msg)
         if ctx:
             ctx.pop()
     msg.recipients = old_recipients
     msg.sender = old_sender
Exemple #6
0
 def tearDown(self):
     with app.test_request_context():
         app.mongo.db.decisiontrees.remove()
Exemple #7
0
 def tearDown(self):
     with app.test_request_context():
         app.mongo.db.decisiontrees.remove()