Exemplo n.º 1
0
def test_loading():
    for i in range(7):
        print("load events: ({})".format(i))

        result = try_load(load_events, name)
        check_result(json_dumps(result), min_size)

    logging.info("PASS: loading")
Exemplo n.º 2
0
def test_known_result():
    surebets_other, surebets_posit = read_sample("known.pkl")
    exclude_posit(surebets_other, surebets_posit)

    with open(path.join(resource_dir, "knownResult.json")) as file_result:
        surebets_result = json.load(file_result)

    assert obj_dumps(surebets_other) == json_dumps(surebets_result)

    logging.info("PASS: known")
Exemplo n.º 3
0
def test_known_result():
    with open(path.join(resource_dir, "known.json")) as file_known:
        sample_known = json.load(file_known)
    surebets_posit = mock_load_events(sample_known)

    with open(path.join(resource_dir,
                        "knownResult.json")) as file_known_result:
        surebets_known = json.load(file_known_result)

    assert obj_dumps(surebets_posit) == json_dumps(surebets_known)

    logging.info("PASS: known result")
Exemplo n.º 4
0
def test_loading():
    for i in range(7):
        print("iteration: ({})".format(i))

        result = try_load(load_events, name)
        check_result(json_dumps(result), min_size)

        events_amount = get_events_amount(result["sport_tree"])
        if len(result["events"]) < int(events_amount * allowable_ratio):
            raise LoadException("got too few events")

    logging.info("PASS: loading")
Exemplo n.º 5
0
def test_parse_json():
    sample_html = read_sample(name, FILENAME_PATTERN.format('.html'))
    sample_json = read_sample(name, FILENAME_PATTERN.format('.json'))

    bookmaker = Bookmaker(name)
    parse(sample_html, bookmaker)
    parse_json(sample_json, bookmaker)

    result = read_sample(name, FILENAME_PATTERN.format('result.json'))
    assert json_dumps(result) == obj_dumps(bookmaker)

    logging.info('PASS: known result')
Exemplo n.º 6
0
def test_known_result():
    filename = abs_path(name, 'knownResultIn.html')
    html = read_html(filename)

    filename = abs_path(name, 'knownResultOut.json')
    known_result = read_json(filename)

    surebets = try_parse(parse, html, name)

    assert obj_dumps(surebets) == json_dumps(known_result)

    logging.info('PASS: known result')
Exemplo n.º 7
0
def test_known_result(name, known_result_in_file_extension):
    parse = import_module('surebet.parsing.' + name).parse

    known_result_in = read_sample(name, 'knownResultIn.' + known_result_in_file_extension)
    known_result_out = read_sample(name, 'knownResultOut.json')

    bookmaker = Bookmaker(name)
    try_parse(parse, known_result_in, name, bookmaker=bookmaker)
    bookmaker.format()

    assert obj_dumps(bookmaker) == json_dumps(known_result_out)

    logging.info('PASS: known result')
Exemplo n.º 8
0
def test_known_result():
    filename = path.join(resource_dir, "knownResult.json")
    with open(filename) as file:
        known_res = json.load(file)

    filename = path.join(resource_dir, "knownResult.pkl")
    with open(filename, "rb") as file:
        known_res_sample = pickle.load(file)

    surebets = calc_surebets(*known_res_sample)

    assert obj_dumps(surebets) == json_dumps(known_res)

    logging.info("PASS: known result")
Exemplo n.º 9
0
def test_decrease_known():
    with open(path.join(resource_dir, 'knownDecrease.json')) as file_known:
        surebets = json.load(file_known, cls=SurebetsJSONDecoder)

    posit = mock_posit()
    posit.surebets = surebets
    mock_decrease_marks(posit)

    with open(path.join(resource_dir,
                        'knownDecreaseResult.json')) as file_known_result:
        surebets_known = json.load(file_known_result)

    assert obj_dumps(posit.surebets) == json_dumps(surebets_known)

    logging.info("PASS: decrease and restore")
Exemplo n.º 10
0
def test_searching():
    fonbet_html = read_html('fonbet')
    fonbet_json = read_json('fonbet')
    marat_json = read_json('marat')
    olimp_json = read_json('olimp')

    bookmakers = Bookmakers()
    fonbet_parse(fonbet_html, bookmakers.fonbet)
    fonbet_parse_json(fonbet_json, bookmakers.fonbet)
    marat_parse(marat_json, bookmakers.marat)
    olimp_parse(olimp_json, bookmakers.olimp)

    surebets = find_surebets(bookmakers)
    surebets_known = read_json('surebets')

    assert obj_dumps(surebets) == json_dumps(surebets_known)