def test_get_role_label(): config = load_config_file(False) factory = MemberFactory(config, None, None, None) vacation_end = 999999999999999999 assert factory.get_role_label( 'member', 0, 'good', MemberVacation(tag='#AAA'), True, False) == config['strings']['roleBlacklisted'] assert factory.get_role_label( 'leader', 100, 'bad', MemberVacation(tag='#AAA'), True, False) == config['strings']['roleBlacklisted'] assert factory.get_role_label('leader', 100, 'bad', MemberVacation(tag='#AAA'), False, False) == config['strings']['roleVacation'] assert factory.get_role_label( 'leader', 100, 'bad', None, False, False) == config['strings']['roleInactive'].format(days=100) assert factory.get_role_label('leader', 0, 'good', None, False, False) == config['strings']['roleLeader'] assert factory.get_role_label('coLeader', 0, 'good', None, False, False) == config['strings']['roleCoLeader'] assert factory.get_role_label('elder', 0, 'good', None, False, False) == config['strings']['roleElder'] assert factory.get_role_label('member', 0, 'good', None, False, False) == config['strings']['roleMember'] assert factory.get_role_label('leader', 0, 'good', None, False, True) == config['strings']['roleNoPromote']
def get_vacation_list(sheet, sheet_id): try: values = sheet.values() \ .get(spreadsheetId=sheet_id, range=VACATION_RANGE) \ .execute() \ .get('values', []) now = datetime.utcnow().date() vacations = [] for (member_name, member_tag, start_date, end_date, notes) in values: vacation_end = datetime.strptime(end_date, '%m/%d/%Y').date() if vacation_end >= now: vacations.append( MemberVacation(tag=member_tag, start_date=start_date, end_date=end_date, notes=notes)) return vacations except Exception as e: logging.error(e) logging.error( 'Unable to get vacation data from Google Sheets {}'.format( sheet_id))
def __process_special_status(config): for demerit_type in ['blacklist', 'no_promote']: demerits = {} for tag in config['members'][demerit_type]: demerits[tag] = Demerit(tag=tag, status=demerit_type) config['members'][demerit_type] = demerits vacations = {} for tag in config['members']['vacation']: vacations[tag] = MemberVacation(tag=tag) config['members']['vacation'] = vacations return config