Beispiel #1
0
def refresh_calnet_attributes():
    from boac.merged import calnet
    from boac.models.authorized_user import AuthorizedUser
    from boac.models import json_cache
    active_uids = {u.uid for u in AuthorizedUser.get_all_active_users()}
    json_cache.clear('calnet_user_for_uid_%')
    new_attrs = calnet.get_calnet_users_for_uids(app, active_uids)
    app.logger.info(f'Cached {len(new_attrs)} CalNet records for {len(active_uids)} active users')
Beispiel #2
0
 def test_academic_standing_options(self):
     json_cache.clear('%')
     assert json_cache.fetch(
         'cohort_filter_options_academic_standing') is None
     options = academic_standing_options(2172)
     assert len(options) == 4
     assert json_cache.fetch(
         'cohort_filter_options_academic_standing') is not None
Beispiel #3
0
 def test_academic_plans_for_cohort_owner(self):
     json_cache.clear('%')
     assert json_cache.fetch(
         f'cohort_filter_options_academic_plans_for_{coe_advisor}') is None
     options = academic_plans_for_cohort_owner(coe_advisor)
     assert len(options) == 5
     assert json_cache.fetch(
         f'cohort_filter_options_academic_plans_for_{coe_advisor}'
     ) is not None
Beispiel #4
0
def load_filtered_cohort_counts():
    from boac.models.cohort_filter import CohortFilter
    from boac.models import json_cache
    json_cache.clear('cohort_filter_options_%')
    for cohort in CohortFilter.query.all():
        # Remove!
        cohort.clear_sids_and_student_count()
        cohort.update_alert_count(None)
        # Reload!
        cohort.to_api_json(include_students=False,
                           include_alerts_for_user_id=cohort.owner_id)
 def test_user_expired_according_to_calnet(self, app, client):
     """Fails if user has no record in LDAP."""
     with override_config(app, 'DEVELOPER_AUTH_ENABLED', True):
         from boac.models import json_cache
         json_cache.clear('%')
         self._api_dev_auth_login(
             client,
             params={
                 'uid': no_calnet_record_for_uid,
                 'password': app.config['DEVELOPER_AUTH_PASSWORD'],
             },
             expected_status_code=403,
         )
Beispiel #6
0
 def test_two_terms(self, app):
     """Contains two items when current and future terms are consecutive."""
     json_cache.clear('%')
     with override_config(app, 'CANVAS_CURRENT_ENROLLMENT_TERM', 'Summer 2021'), \
             override_config(app, 'CANVAS_FUTURE_ENROLLMENT_TERM', 'Fall 2021'):
         options = grading_terms()
         assert options == [
             {
                 'name': 'Summer 2021 (active)',
                 'value': '2215'
             },
             {
                 'name': 'Fall 2021 (future)',
                 'value': '2218'
             },
         ]
Beispiel #7
0
 def flush_cached(self):
     clear(f'boa_user_session_{self.user_id}')
Beispiel #8
0
 def flush_cache_for_id(cls, user_id):
     clear(f'boa_user_session_{user_id}')
Beispiel #9
0
 def test_colleges(self):
     json_cache.clear('%')
     assert json_cache.fetch('cohort_filter_options_colleges') is None
     options = colleges()
     assert len(options) == 3
     assert json_cache.fetch('cohort_filter_options_colleges') is not None
Beispiel #10
0
def refresh_current_term_index():
    from boac.merged import sis_terms
    from boac.models import json_cache
    json_cache.clear('current_term_index')
    sis_terms.get_current_term_index()
    app.logger.info('Cached current and future SIS terms')