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();
Esempio n. 2
0
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])
Esempio n. 3
0
    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()
Esempio n. 4
0
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
Esempio n. 5
0
 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):
     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)
Esempio n. 8
0
 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):
     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
Esempio n. 10
0
 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()
Esempio n. 11
0
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'])
Esempio n. 12
0
 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()
Esempio n. 13
0
 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)
Esempio n. 14
0
 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()
Esempio n. 15
0
 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()
Esempio n. 16
0
def test_index(original_sudoku):
    response = app.test_client().get("/")
    assert response.status_code == 200
Esempio n. 17
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
     for x in Report.all():
         x.delete()
Esempio n. 18
0
 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)
Esempio n. 20
0
def step_impl(context, salary):
    context.app = app.test_client()
    context.salary = float(salary)
Esempio n. 21
0
def get_flask_test_client():
    app.testing = True
    return app.test_client()
 def setUpClass(cls):
     app.config['TESTING'] = True
     cls.app = app.test_client()