Пример #1
0
def registerApplication(comments, needs, user, partnerUsername, seatRollover,
                        preferredRoom, rank):
    try:
        season = getCurrentOrNext()
        application = Application(
            status=ApplicationStatus.SUBMITTED,
            needs=needs,
            user=user,
            partnerUsername=partnerUsername,
            comments=comments,
            seatRollover=seatRollover,
            preferredRoom=preferredRoom,
            rank=rank,
            applicationSeason=season,
        )
        db.session.add(application)
        db.session.commit()
        connectApplication(application)
        return application.to_json(), 201
    except SQLAlchemyError as err:
        print(err)
        return "", 400
Пример #2
0
def getCurrentSeason():
    currApplication = applicationSeasonService.getCurrentOrNext()
    return jsonify(currApplication.to_json()) if currApplication else Response(
        "{}", 200)
Пример #3
0
def test_getCurrent_with_no_season(mocker):
    mocker.patch.object(db.session, "query")
    filter = mockFilterAll()
    db.session.query.return_value = filter
    with pytest.raises(TypeError):
        applicationSeasonService.getCurrentOrNext()
Пример #4
0
def test_getCurrent_with_two_seasons(mocker):
    season1, season2 = generateTestSeason(mocker, 2)
    filter = mockFilterAll(returnValue=[season1, season2])
    db.session.query.return_value = filter
    assert applicationSeasonService.getCurrentOrNext() == season1
Пример #5
0
def test_getCurrent_with_single_season(mocker):
    season = generateTestSeason(mocker, 1)
    filter = mockFilterAll(returnValue=[season])
    db.session.query.return_value = filter
    assert season == applicationSeasonService.getCurrentOrNext()