예제 #1
0
def test_signin_invalid_credentials():
    source = AdUnisHSR()

    with pytest.raises(AuthenticationException) as exceptionInfo:
        source.signin('user', 'password')

    assert str(exceptionInfo.value)[:27] == "Authentication has failed ("
예제 #2
0
def test_signin_invalid_credentials():
    source = AdUnisHSR()

    with pytest.raises(AuthenticationException) as exceptionInfo:
        source.signin('user', 'password')

    assert str(exceptionInfo.value)[:27] == "Authentication has failed ("
예제 #3
0
def test_all_modules_ids_signed_in_happy_path():
    source = AdUnisHSR()

    username, password = utils.parse_user_credentials('auth.cfg')
    response = source.signin(username, password)
    modules = source.all_modules_ids()
    assert len(modules) > 20
    assert modules['InfSys'] == '51677'
예제 #4
0
def test_lectures_times_happy_path():
    source = AdUnisHSR()

    username, password = utils.parse_user_credentials('auth.cfg')
    response = source.signin(username, password)

    if 'CN1' in source.all_modules_ids():
        # Herbstsemester
        lectures_times = source.lectures_times(['CN1'])
        raise Exception("NOT TESTET YET! PLEASE IMPLEMENT ME!")
    else:
        # Fruehlungssemester
        lectures_times = source.lectures_times(['CN2'])['CN2']
        # Uebungen
        uebungen = [lectures_times for lt in lectures_times if lt['type'] == 'u']
        assert len(uebungen) >= 2 and len(uebungen) < len(lectures_times)
        # Praktikas
        praktikas = [lectures_times for lt in lectures_times if lt['type'] == 'u']
        assert len(praktikas) >= 4 and len(uebungen) < len(lectures_times)
        # Vorlesungen
        vorlesungen = [lectures_times for lt in lectures_times if lt['type'] == 'v']
        assert len(vorlesungen) >= 2 and len(uebungen) < len(lectures_times)

    # TODO: Test with other modules
    begin_first_lesson = time(7, 5)
    begin_last_lesson = time(20, 5)
    for lesson in lectures_times:
        assert re.match('^CN(1|2)(Prak)?-(u|v|p)[0-9][0-9]?$', lesson['name']) is not None
        assert re.match('^CN(1|2)(Prak)?$', lesson['abbrev']) is not None
        assert begin_first_lesson <= lesson['start_time'] <= begin_last_lesson
        assert re.match('^[A-Z]{3}( [A-Z]{3})*$', lesson['teacher']) is not None
        assert lesson['day'] in ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
        assert lesson['class'] is not None
        assert lesson['team'] is None or re.match('^[0-9]$', lesson['class'])
        assert re.match('^[1-9]\.[0-9]*[a-z]?$', lesson['room']) is not None
        assert lesson['weeks'] is None or re.match('^([0-9]{1,2}(\,[0-9]{1,2})*)$', lesson['weeks']) is not None
예제 #5
0
    module_spec = {'MsTe': {'v': 2, 'u': 2},
                   'AD2': {'v': 2, 'u': 2},
                   'BuRe1': [
                    {'abbrev': 'ReIng', 'v': 2},
                    {'abbrev': 'BuPl', 'v': 1, 'u': 1},
                   ],
                   'CPl': {'v': 2, 'u': 2},
                   'MGE': {'v': 2, 'u': 2},
                   'SE1': {'v': 2, 'u': 2},
                   'WED2': {'v': 2, 'u': 2},
                   'PrFm': {'v': 2, 'u': 2}
                   }

    source = AdUnisHSR()
    username, password = utils.parse_user_credentials('auth.cfg')
    response = source.signin(username, password)

    filters = [
                restrictions.InTimeRange(time(7, 0), time(18, 00)),
                restrictions.MinChance(30),
                restrictions.FreeTime(3, range(5), time(12), time(23)),
                # restrictions.FreeTime(1, range(5), time(6), time(23))
                ]

    planner = Planner(module_spec.keys(), source)
    solutions = planner.solve(filters)

    for solution in solutions:
        planner.verify(module_spec, solution)

    # Print max. 10 timetables
예제 #6
0
            'v': 2,
            'u': 2
        },
        'WED2': {
            'v': 2,
            'u': 2
        },
        'PrFm': {
            'v': 2,
            'u': 2
        }
    }

    source = AdUnisHSR()
    username, password = utils.parse_user_credentials('auth.cfg')
    response = source.signin(username, password)

    filters = [
        restrictions.InTimeRange(time(7, 0), time(18, 00)),
        restrictions.MinChance(30),
        restrictions.FreeTime(3, range(5), time(12), time(23)),
        # restrictions.FreeTime(1, range(5), time(6), time(23))
    ]

    planner = Planner(module_spec.keys(), source)
    solutions = planner.solve(filters)

    for solution in solutions:
        planner.verify(module_spec, solution)

    # Print max. 10 timetables
예제 #7
0
def test_signin_valid_credentials():
    source = AdUnisHSR()
    username, password = utils.parse_user_credentials('auth.cfg')
    source.signin(username, password)
예제 #8
0
def test_signin_valid_credentials():
    source = AdUnisHSR()
    username, password = utils.parse_user_credentials('auth.cfg')
    response = source.signin(username, password)
    assert len(response.text) > 100