Exemple #1
0
async def code_wheel(request):
    static_wheel = request.query.get("static_wheel")
    moving_wheel = request.query.get("moving_wheel")
    cell = request.query.get("cell")

    codes_file = open(BASE_DIR / "app/data/indy4a_code_wheel.json")
    codes_string = codes_file.read()
    codes = json.loads(codes_string)

    code = get_code(static_wheel.upper(), moving_wheel.upper(), int(cell), codes)

    return web.json_response({"code": code})
def test_invalid_cell_number(cell):
    with pytest.raises(InvalidWheelParam):
        get_code("A", "3", cell, codes)
def test_invalid_moving_wheel_key():
    with pytest.raises(InvalidWheelParam):
        get_code("A", "33", 1, codes)
def test_invalid_static_wheel_key():
    with pytest.raises(InvalidWheelParam):
        get_code("AA", "3", 1, codes)
def test_get_code_moving_wheel_beyond_edge(static_wheel, moving_wheel, cell,
                                           expected):
    code = get_code(static_wheel, moving_wheel, cell, codes)
    assert code == expected
def test_get_code_starting_point(static_wheel, moving_wheel, cell, expected):
    code = get_code(static_wheel, moving_wheel, cell, codes)
    assert code == expected