Пример #1
0
def assert_quota(c, user, diff_daily, diff_semesterly):
    """Assert the quota for a user is what we expect.

    Typically, you want to pass a negative number for diff_daily and
    diff_semesterly. This number is added to the start quota before assertion.
    """
    start = 1000, 10000
    with mock.patch('ocflib.printing.quota.daily_quota', return_value=start[0]), \
            mock.patch('ocflib.printing.quota.SEMESTERLY_QUOTA', start[1]):
        assert (get_quota(c, user) == UserQuota(
            user, FAKE_DAILY_QUOTA + diff_daily,
            FAKE_SEMESTERLY_QUOTA + diff_semesterly))
Пример #2
0
def test_desk_staff_have_infinite_quota(mysql_connection):
    assert (get_quota(mysql_connection,
                      'testopstaff') == UserQuota('testopstaff', 500, 500))
Пример #3
0
def test_groups_have_zero_quota(mysql_connection):
    assert (get_quota(mysql_connection, 'ggroup') == UserQuota('ggroup', 0, 0))
Пример #4
0
def test_non_existent_users_have_zero_quota(mysql_connection):
    assert (get_quota(mysql_connection,
                      'nonexist') == UserQuota('nonexist', 0, 0))
Пример #5
0
def test_pubstaff_has_infinite_quota(mysql_connection):
    assert (
        get_quota(mysql_connection, 'pubstaff') ==
        UserQuota('pubstaff', 500, 500)
    )