Пример #1
0
def tables():
    from tensorhive.database import Base, engine, db_session
    from tensorhive.models.User import User
    from tensorhive.models.Group import Group, User2Group
    from tensorhive.models.Reservation import Reservation
    from tensorhive.models.Resource import Resource
    from tensorhive.models.Restriction import Restriction, Restriction2Assignee, Restriction2Resource
    from tensorhive.models.RestrictionSchedule import RestrictionSchedule
    from tensorhive.models.Role import Role
    from tensorhive.models.RevokedToken import RevokedToken
    Base.metadata.create_all(engine)
    db_session.remove()  # that makes sure we won't be holding on to any cached entities between test cases
    yield
    Base.metadata.drop_all(engine)
Пример #2
0
def test_update_restriction_incorrect_data(tables, client, restriction):
    old_start_date = restriction.starts_at
    old_end_date = restriction.ends_at
    data = {
        'startsAt':
        '2200-01-01T10:00:00.000Z',  # start date is after the end date, this request shouldn't be accepted
        'endsAt': '2199-02-01T10:00:00.000Z',
    }
    resp = client.put(ENDPOINT + '/' + str(restriction.id),
                      headers=HEADERS,
                      data=json.dumps(data))

    db_session.remove(
    )  # make sure we'll get the restriction from the DB, and not from memory
    restriction = Restriction.get(restriction.id)
    assert resp.status_code == HTTPStatus.UNPROCESSABLE_ENTITY
    assert restriction.starts_at == old_start_date
    assert restriction.ends_at == old_end_date
Пример #3
0
 def shutdown_session(exception=None):
     db_session.remove()