def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') # generate data for reports self.r = Report(start=date(year=2011, month=2, day=1), end=date(year=2011, month=3, day=1), finished=True) self.r.put(); stats = { 'id': str(self.r.key()), 'stats': { '0000_01': { 'id': '01', 'table': '0000', 'def': 1, 'deg': 2 }, '0000_02': { 'id': '02', 'table': '0000', 'def': 1, 'deg': 2 }, '0001_02': { 'id': '02', 'table': '0001', 'def': 1, 'deg': 2 } } } StatsStore(report_id=str(self.r.key()), json=json.dumps(stats)).put();
def test_solve(original_sudoku_single, solved_sudoku): data = [] i = 0 for y in range(9): for x in range(9): input_key = str(y) + str(x) data.append({ "name": input_key, "value": original_sudoku_single[i] }) i += 1 json_data = json.dumps(data) response = app.test_client().post( "/solve", data=json_data, content_type="application/json", ) assert response.status_code == 200 response_solution = response.get_json() for y in range(9): for x in range(9): assert str(response_solution[f"{x}{y}"]) == str( solved_sudoku[y][x])
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') # generate data for reports self.r = Report(start=date(year=2011, month=2, day=1), end=date(year=2011, month=3, day=1), finished=True) self.r.put() stats = { 'id': str(self.r.key()), 'stats': { '0000_01': { 'id': '01', 'table': '0000', 'def': 1, 'deg': 2 }, '0000_02': { 'id': '02', 'table': '0000', 'def': 1, 'deg': 2 }, '0001_02': { 'id': '02', 'table': '0001', 'def': 1, 'deg': 2 } } } StatsStore(report_id=str(self.r.key()), json=json.dumps(stats)).put()
def client_mocked(mocker): mocker.patch("flask_sqlalchemy.SQLAlchemy.init_app", return_value=True) mocker.patch("flask_sqlalchemy.SQLAlchemy.create_all", return_value=True) mocker.patch("application.app.get_task", return_value=MockedTask(1, "mock", datetime.now())) client = app.test_client() return client
def setUp(self): for x in models.CELL_BLACK_LIST[:]: models.CELL_BLACK_LIST.pop() app.config['TESTING'] = True self.login('*****@*****.**', 'testuser') self.app = app.test_client() self.user = User(user=users.get_current_user()) self.user.put()
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() self.area = Area(geo='[[[-61.5,-12],[-61.5,-11],[-60.5,-11],[-60.5,-12]]]', added_by=users.get_current_user(), type=1, cell=self.cell)
def setUp(self): for x in models.CELL_BLACK_LIST[:]: models.CELL_BLACK_LIST.pop() app.config['TESTING'] = True self.login('*****@*****.**', 'testuser') self.app = app.test_client() for x in Cell.all(): x.delete() r = Report(start=date.today(), finished=False) r.put() self.r = r
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() for x in Note.all(): x.delete() self.when = datetime.now() self.note = Note(msg='test msg', added_by=users.get_current_user(), cell=self.cell, added_on=self.when) self.note.put()
def client(): test_db, app.config['DATABASE'] = tempfile.mkstemp() app.config['TESTING'] = True client = app.test_client() with app.app_context(): db.init_app(app) db.create_all() yield client with app.app_context(): db.drop_all() os.close(test_db) os.unlink(app.config['DATABASE'])
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() self.login('*****@*****.**', 'testuser') for x in Area.all(): x.delete() for x in Cell.all(): x.delete() r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() self.area = Area(geo='[]', added_by=users.get_current_user(), type=1, cell=self.cell) self.area.put()
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() r = Report(start=date.today(), finished=False) r.put() self.r = r self.cell = Cell(x=0, y=0, z=2, report=self.r, ndfi_high=1.0, ndfi_low=0.0) self.cell.put() self.area = Area( geo='[[[-61.5,-12],[-61.5,-11],[-60.5,-11],[-60.5,-12]]]', added_by=users.get_current_user(), type=1, cell=self.cell)
def test_index(original_sudoku): response = app.test_client().get("/") assert response.status_code == 200
def setUp(self): app.config['TESTING'] = True self.app = app.test_client() for x in Report.all(): x.delete()
def setUp(self): app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' self.c = app.test_client() db.create_all(app=app)
def step_impl(context, salary): context.app = app.test_client() context.salary = float(salary)
def get_flask_test_client(): app.testing = True return app.test_client()
def setUpClass(cls): app.config['TESTING'] = True cls.app = app.test_client()