Ejemplo n.º 1
0
def test_dump_data():
    one_hashed = sha1(bytes(1)).hexdigest()
    two_hashed = sha1(bytes(2)).hexdigest()

    SearchConfigs.dump_data()

    SearchConfigs.set_user_cfg(1, 10, 'n')
    SearchConfigs.set_user_cfg(1, 20, 'm')
    SearchConfigs.set_user_cfg(2, 30, 'n')
    SearchConfigs.set_user_cfg(2, 40, 'm')

    SearchConfigs.dump_data()

    SearchConfigs.set_user_cfg(1, 999, 'n')
    SearchConfigs.set_user_cfg(1, 998, 'm')
    SearchConfigs.set_user_cfg(2, 111, 'n')
    SearchConfigs.set_user_cfg(2, 112, 'm')

    assert SearchConfigs.get_user_show_first_n(1) == 999
    assert SearchConfigs.get_user_show_min_threshold(1) == 998

    assert SearchConfigs.get_user_show_first_n(2) == 111
    assert SearchConfigs.get_user_show_min_threshold(2) == 112

    SearchConfigs.init_data()

    assert SearchConfigs.get_user_show_first_n(1) == 10
    assert SearchConfigs.get_user_show_min_threshold(1) == 20

    assert SearchConfigs.get_user_show_first_n(2) == 30
    assert SearchConfigs.get_user_show_min_threshold(2) == 40
Ejemplo n.º 2
0
def test_normalize_user_data():
    data = SearchConfigs.normalize_user_data()

    one_hashed = sha1(bytes(1)).hexdigest()
    two_hashed = sha1(bytes(2)).hexdigest()
    three_hashed = sha1(bytes(3)).hexdigest()

    assert data[one_hashed]['n'] == SearchConfigs.get_user_show_first_n(1)
    assert data[one_hashed]['m'] == SearchConfigs.get_user_show_min_threshold(1)

    assert data[two_hashed]['n'] == SearchConfigs.get_user_show_first_n(2)
    assert data[two_hashed]['m'] == SearchConfigs.get_user_show_min_threshold(2)

    assert data[three_hashed]['n'] == SearchConfigs.get_user_show_first_n(3)
    assert data[three_hashed]['m'] == SearchConfigs.get_user_show_min_threshold(3)
Ejemplo n.º 3
0
def test_get_user_show_min_threshold():
    assert SearchConfigs.get_user_show_min_threshold(1) == 1
    assert SearchConfigs.get_user_show_min_threshold(2) == 30
    assert SearchConfigs.get_user_show_min_threshold(3) == 90