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))
def test_desk_staff_have_infinite_quota(mysql_connection): assert (get_quota(mysql_connection, 'testopstaff') == UserQuota('testopstaff', 500, 500))
def test_groups_have_zero_quota(mysql_connection): assert (get_quota(mysql_connection, 'ggroup') == UserQuota('ggroup', 0, 0))
def test_non_existent_users_have_zero_quota(mysql_connection): assert (get_quota(mysql_connection, 'nonexist') == UserQuota('nonexist', 0, 0))
def test_pubstaff_has_infinite_quota(mysql_connection): assert ( get_quota(mysql_connection, 'pubstaff') == UserQuota('pubstaff', 500, 500) )