Exemplo n.º 1
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();
Exemplo 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])
Exemplo 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()
Exemplo 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
Exemplo 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()
Exemplo n.º 6
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()
Exemplo n.º 7
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)
Exemplo 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
Exemplo n.º 9
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
Exemplo 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()
Exemplo 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'])
Exemplo 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()
Exemplo 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)
Exemplo 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()
Exemplo 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()
Exemplo n.º 16
0
def test_index(original_sudoku):
    response = app.test_client().get("/")
    assert response.status_code == 200
Exemplo n.º 17
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
     for x in Report.all():
         x.delete()
Exemplo n.º 18
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
     for x in Report.all():
         x.delete()
Exemplo n.º 19
0
    def setUp(self):

        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
        self.c = app.test_client()
        db.create_all(app=app)
Exemplo n.º 20
0
def step_impl(context, salary):
    context.app = app.test_client()
    context.salary = float(salary)
Exemplo 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()