Example #1
0
async def test_ocrscanner_generate_system_map(session, f_asheet_ocrscanner, f_ocr_testbed):
    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    sys_map = o_scanner.generate_system_map()

    assert sys_map['HYADES SECTOR GH-V D2-135'] == 'Hyades Sector GH-V d2-135'
    assert sys_map['LALANDE 39866'] == 'Lalande 39866'
Example #2
0
async def test_ocrscanner_should_update_triggers_stale(session, f_asheet_ocrscanner, f_ocr_testbed):
    trigger = f_ocr_testbed[0][0]
    old_trigger = OCRTrigger(system='Adeo', updated_at=(trigger.updated_at - datetime.timedelta(days=14)))

    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    sheet_date = datetime.datetime.strptime(o_scanner.cells_row_major[0][2], "%Y-%m-%d %H:%M:%S")
    assert o_scanner.should_update_trigger(old_trigger, sheet_date)
Example #3
0
async def test_ocrscanner_should_update_triggers_near_tick(session, f_asheet_ocrscanner, f_ocr_testbed):
    trigger = f_ocr_testbed[0][0]

    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    sheet_date = datetime.datetime.strptime(o_scanner.cells_row_major[0][2], "%Y-%m-%d %H:%M:%S")
    next_tick = cog.util.next_weekly_tick(sheet_date)
    just_past = next_tick + datetime.timedelta(hours=1)
    assert o_scanner.should_update_trigger(trigger, just_past)
Example #4
0
async def test_ocrscanner_parse_sheet(session, f_asheet_ocrscanner, f_ocr_testbed, f_global_testbed):
    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    o_scanner.parse_sheet(session)

    with cogdb.session_scope(cogdb.Session) as new_session:
        assert new_session.query(OCRTracker).filter(OCRTracker.system == 'Adeo').one().fort == 3576
        assert new_session.query(OCRPrep).filter(OCRPrep.system == 'Bolg').one().merits == 8592
        assert new_session.query(OCRTrigger).filter(OCRTrigger.system == 'Adeo').one().fort_trigger == 3576
        assert new_session.query(Global).all()[-1].consolidation == 76
Example #5
0
async def test_ocrscanner_ocr_preps(session, f_asheet_ocrscanner, f_ocr_testbed):
    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    sheet_date = datetime.datetime.strptime(o_scanner.cells_row_major[0][2], "%Y-%m-%d %H:%M:%S")

    expect = {
        'merits': 8592,
        'system': 'Bolg',
        'updated_at': datetime.datetime(2021, 8, 23, 20, 32, 47)
    }
    sys_map = o_scanner.generate_system_map()
    result = o_scanner.ocr_preps(sheet_date, sys_map)
    assert result['Bolg'] == expect
Example #6
0
async def test_ocrscanner_ocr_trackers(session, f_asheet_ocrscanner, f_ocr_testbed):
    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    sheet_date = datetime.datetime.strptime(o_scanner.cells_row_major[0][2], "%Y-%m-%d %H:%M:%S")

    expect = {
        'fort': 3576,
        'system': 'Adeo',
        'um': 0,
        'updated_at': datetime.datetime(2021, 8, 23, 20, 32, 47)
    }

    result = o_scanner.ocr_trackers(sheet_date, o_scanner.generate_system_map())
    assert result['Adeo'] == expect
Example #7
0
async def test_ocrscanner_should_update_triggers_none(session, f_asheet_ocrscanner, f_ocr_testbed):
    o_scanner = OCRScanner(f_asheet_ocrscanner)
    await o_scanner.update_cells()
    sheet_date = datetime.datetime.strptime(o_scanner.cells_row_major[0][2], "%Y-%m-%d %H:%M:%S")
    assert o_scanner.should_update_trigger(None, sheet_date)