def setup():
    with suppress(OSError):
        remove('cve_cpe.db')
    sr.QUERIES.update(TEST_QUERIES)
    cpe_base = sr.setup_cpe_table(dp.extract_cpe(PATH_TO_TEST + EXTRACT_CPE_XML))
    cve_base, summary_base = dp.extract_cve(PATH_TO_TEST + EXTRACT_CVE_JSON)
    cve_base = sr.setup_cve_feeds_table(cve_list=cve_base)
    summary_base = sr.setup_cve_summary_table(summary_list=summary_base)

    with DatabaseInterface(PATH_TO_TEST + 'test_update.db') as db:
        db.execute_query(query=QUERIES['create_cpe_table'].format('cpe_table'))
        db.insert_rows(query=QUERIES['insert_cpe'].format('cpe_table'), input_data=cpe_base)
        db.execute_query(query=QUERIES['create_cve_table'].format('cve_table'))
        db.execute_query(query=QUERIES['create_summary_table'].format('summary_table'))
        db.insert_rows(query=QUERIES['insert_cve'].format('cve_table'), input_data=cve_base)
        db.insert_rows(query=QUERIES['insert_summary'].format('summary_table'), input_data=summary_base)

        db.execute_query(query=TEST_QUERIES['test_create_update'].format('outdated'))
        db.execute_query(query=TEST_QUERIES['test_create_update'].format('new'))
        db.insert_rows(query=TEST_QUERIES['test_insert_cve_id'].format('outdated'), input_data=[('CVE-2018-0001', 2018), ('CVE-2018-0002', 2018)])
        db.insert_rows(query=TEST_QUERIES['test_insert_cve_id'].format('new'), input_data=[('CVE-2018-0002', 2018), ('CVE-2018-0003', 2018)])

    yield

    with suppress(OSError):
        remove(PATH_TO_TEST + 'test_update.db')
        remove(PATH_TO_TEST + 'test_import.db')
        remove(PATH_TO_TEST + 'test_output.db')
def test_setup_cve_summary_table():
    summary_input = [
        CveSummaryEntry('CVE-2018-20229', 'some description ...', {'cvssV2': '5.3'}),
        CveSummaryEntry('CVE-2018-0010', 'foobar', {'cvssV2': '7.3', 'cvssV3': '8.3'}),
    ]
    expected_output = [
        ('CVE-2018-20229', '2018', 'some description ...', '5.3', 'N/A'),
        ('CVE-2018-0010', '2018', 'foobar', '7.3', '8.3'),
    ]
    summary_result = sr.setup_cve_summary_table(summary_input)
    assert summary_result == expected_output