Beispiel #1
0
def _test_get_failed_no_such_sheet():
    cdata_loader.init('test_conf.json', 'test')
    cdata_loader.load()

    data = cdata_loader.get('skilll', '10209013')
    assert data == {}

    cdata_loader.destroy()
Beispiel #2
0
def _test_get_keys_failed_no_such_sheet():
    cdata_loader.init('test_conf.json', 'test')
    cdata_loader.load()

    keys = cdata_loader.get_keys('skilll')
    assert keys == []

    cdata_loader.destroy()
Beispiel #3
0
def _test_load_failed_cannt_open_file():
    cdata_loader.init('test_conf.json', 'teast')
    try:
        cdata_loader.load()
    except Exception as e:
        assert e.message == 'Can\'t open data file'

    cdata_loader.destroy()
Beispiel #4
0
def _test_load_failed_bad_csv():
    cdata_loader.init('test_conf.ecsv.json', 'test')
    try:
        cdata_loader.load()
    except Exception as e:
        assert e.message == 'Csv file isn\'t a matrix'

    cdata_loader.destroy()
Beispiel #5
0
def _test_load_failed_bad_conf():
    cdata_loader.init('test_conf.econf.json', 'test')
    try:
        cdata_loader.load()
    except Exception as e:
        assert e.message == 'Keys len < 1'

    cdata_loader.destroy()
Beispiel #6
0
def _test_load_failed_bad_json():
    cdata_loader.init('test_conf.bad.json', 'test')
    try:
        cdata_loader.load()
    except Exception as e:
        assert e.message == 'Bad json file'

    cdata_loader.destroy()
Beispiel #7
0
def _test_load_and_get_keys_succeed():
    cdata_loader.init('test_conf.json', 'test')
    cdata_loader.init('test_conf.json', 'test')
    cdata_loader.load()

    keys = cdata_loader.get_keys('skill')
    assert len(keys) == 200
    assert 10209013 in keys

    cdata_loader.destroy()
Beispiel #8
0
def _test_load_and_get_succeed():
    cdata_loader.init('test_conf.json', 'test')
    cdata_loader.load()
    cdata_loader.load()

    data = cdata_loader.get('skill', '10209013')
    assert len(data) == 17
    assert data['id'] == 10209013

    cdata_loader.destroy()
    cdata_loader.destroy()
Beispiel #9
0
def _test_efficiency():
    cdata_loader.init('test_conf.json', 'test')
    cdata_loader.load()

    keys = cdata_loader.get_keys('skill')
    keys = [str(k) for k in keys]
    k = 0

    for i in xrange(2, 6):
        count = 10**i
        t1 = time.time()
        for j in xrange(count):
            cdata_loader.get('skill', keys[k % len(keys)])
            #cdata_loader.get('skill', '10209013')
            k += 1

        t2 = time.time()
        print 'get %d consume %s' % (count, t2 - t1)

    cdata_loader.destroy()