def test_getUserMetricsFalse(self):
     tester = app.test_client(self)
     usr = "******" + str(uuid.uuid4())
     response = tester.post('/getUserMetrics',
                            data=json.dumps(dict(userid=usr, )),
                            content_type='application/json')
     assert response.status_code == 400
 def test_signInFalse(self):
     tester = app.test_client(self)
     usr = "******" + str(uuid.uuid4())
     response = tester.post('/signin',
                            data=json.dumps(
                                dict(username=usr, password='******')),
                            content_type='application/json')
     assert response.status_code == 400
 def test_signInTrue(self):
     tester = app.test_client(self)
     response = tester.post('/signin',
                            data=json.dumps(
                                dict(username='******',
                                     password='******')),
                            content_type='application/json')
     assert response.status_code == 200
 def post_data():
     usr = "******" + str(uuid.uuid4())
     response = app.test_client().post(
         '/addUser',
         data=json.dumps(dict(username=usr, password='******')),
         content_type='application/json')
     if response.status_code != 200:
         responseCode = 1
示例#5
0
def client():
    Base.metadata.drop_all(bind=engine)
    Base.metadata.create_all(bind=engine)
    es.indices.delete(index='posts', ignore=[400, 404])

    app.config['TESTING'] = True

    with app.test_client() as client:
        yield client
 def test_AddUserMetricCreation(self):
     tester = app.test_client(self)
     usr = "******" + str(uuid.uuid4())
     response = tester.post('/addUser',
                            data=json.dumps(
                                dict(username=usr, password='******')),
                            content_type='application/json')
     assert checkUserExistsInUserMetrics(
         container_userMetrics, response.json.get('userid')) == True
示例#7
0
 def setUp(self):
     app.config['SECRET_KEY'] = "TestKey"
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     app.config['DEBUG'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(BASE_DIR, TEST_DB)
     self.app = app.test_client()
     db.create_all()
     self.joke = Joke("Sample text", 1)
     self.joke.save()
示例#8
0
    def setUp(self):
        self.app = app.test_client()
        database.db_connect_test()

        achievements.reset_achievements()
        achievements.reset_achievement_completed()
        player.reset_players()

        self.user = "******"
        self.name = "Test writing"
        self.descr = "Find ways to entertain yourself while writing tests"
        player.create_player(self.user, "test")
示例#9
0
 def setUp(self):
     self.client = app.test_client()  # we instantiate a flask test client-
     db.create_all()  # create the database objects
     # add some fixtures to the database
     self.user1 = User(username='******',
                       password='******',
                       firstname='Philip',
                       lastname='GeLinas',
                       isOwner=False,
                       phone='1234567890')
     self.user2 = User(username='******',
                       password='******',
                       firstname='Tom',
                       lastname='Brady',
                       isOwner=True,
                       phone='0987654321')
     self.property1 = Property(name='Sunset Hotel',
                               address='1234 Pullman Ave',
                               description='Nice place to live!',
                               price='500',
                               rating=4.2)
     self.property2 = Property(name='Bates Motel',
                               address='9876 Cougar Dr',
                               description='A filthy place!',
                               price='275',
                               rating=2.2)
     self.thread1 = Thread(id=7,
                           user1='*****@*****.**',
                           user2='*****@*****.**',
                           subject='Classmates')
     self.thread2 = Thread(id=4,
                           user1='*****@*****.**',
                           user2='*****@*****.**',
                           subject='Football')
     self.message1 = Message(id=5,
                             threadId=7,
                             content='Whats up!',
                             sender='Joe',
                             receiver='Philip')
     self.message2 = Message(id=8,
                             threadId=4,
                             content='Hey dude!',
                             sender='Cam',
                             receiver='Josh')
     db.session.add(self.user1)
     db.session.add(self.user2)
     db.session.add(self.property1)
     db.session.add(self.property2)
     db.session.add(self.thread1)
     db.session.add(self.thread2)
     db.session.add(self.message1)
     db.session.add(self.message2)
     db.session.commit()
示例#10
0
def rig_test_client():
    with testing.postgresql.Postgresql() as postgresql:
        with app.app_context():
            dburl = postgresql.url()
            engine = create_engine(dburl)
            Base.metadata.create_all(engine)
            db_session.bind = engine
            user_datastore = SQLAlchemySessionUserDatastore(db_session,
                                                            User, Role)
            app.config['SQLALCHEMY_DATABASE_URI'] = dburl
            app.config['WTF_CSRF_ENABLED'] = False
            init_app_with_options(user_datastore)
            yield app.test_client(), engine
示例#11
0
 def setUp(self):
     self.app = app.test_client()
     database.db_connect_test()
     player.reset_players()
     character.reset_characters()
     inventory.reset_inventory()
     item.reset_items()
     item.reset_item_types()
     item.reset_item_attributes()
     item.reset_attributes()
     equipment.reset_equipment()
     equipment.reset_slots()
     player.create_player("UserJoe", "test")
示例#12
0
    def setUp(self):
        #Disabling error catching
        app.config['TESTING'] = True
        app.config['CSRF_ENABLED'] = False
        self.app = app.test_client()

        #configure stubs
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()

        self.init_test_db()
 def test_getUserMetricsTrue(self):
     tester = app.test_client(self)
     response = tester.post('/getUserMetrics',
                            data=json.dumps(dict(userid="devesh", )),
                            content_type='application/json')
     assert response.status_code == 200
示例#14
0
from unittest import mock

from backend import app

app = app.test_client()


def set_up():
    app.config.from_object("config.TestingConfig")


def test_index():
    response = app.get("/")
    assert response.status_code == 200
    assert b"Hello World" in response.data


@mock.patch("backend.metrics.influx")
def test_start_game(mock_influx):
    response = app.post("/game/new")
    assert response.status_code == 201
    assert b"Registered new game" in response.data


@mock.patch("backend.metrics.influx")
def test_should_send_metrics_when_starting_a_game(mock_influx):
    app.post("/game/new")
    mock_influx.write.assert_called_once()
示例#15
0
 def setUp(self):
     self.app = app.test_client()
示例#16
0
 def setUp(self):
     self.app = app.test_client()
示例#17
0
def client():
    return app.test_client()
示例#18
0
    def test(self):
        result = app.test_client().get('/api')

        self.assertEqual(result.data.decode('utf-8'), 'Hello people!')
示例#19
0
 def setUpClass(cls):
     cls.client = app.test_client()
示例#20
0
 def setUp(self):
     self.app = app.test_client()
     database.db_connect_test()
 def test_getDatasets(self):
     tester = app.test_client(self)
     response = tester.get('/getDatasets', content_type='html/text')
     assert response.status_code == 200
 def test_newRequestFalse(self):
     tester = app.test_client(self)
     response = tester.post('/signin',
                            data=json.dumps(dict()),
                            content_type='application/json')
     assert response.status_code == 400
示例#23
0
 def setUp(self):
     self.app = app.test_client()
     self.app.testing = True 
示例#24
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
     self.app = app.test_client()
     db.create_all()
示例#25
0
def app():
    return real_app.test_client()