def test_main_submit_db(self, tmpdir, config_e2e):
        orig_db_file = os.path.join(conf.DATA_PATH, "workitems_ids.sqlite3")
        db_file = os.path.join(str(tmpdir), "workitems_copy.sqlite3")
        shutil.copy(orig_db_file, db_file)

        output_file = tmpdir.join("out.xml")
        args = ["-i", db_file, "-o", str(output_file), "-c", config_e2e]

        with patch("dump2polarion.submit_and_verify", return_value=True), patch(
            "dump2polarion.dumper_cli.utils.init_log"
        ):
            retval = dumper_cli.main(args)
        assert retval == 0

        golden_output = "complete_transform.xml"
        with open(os.path.join(conf.DATA_PATH, golden_output), encoding="utf-8") as golden_xml:
            parsed = golden_xml.read()
        with open(str(output_file), encoding="utf-8") as out_xml:
            produced = out_xml.read()
        assert produced == parsed

        conn = dbtools._open_sqlite(db_file)
        cur = conn.cursor()
        select = "SELECT count(*) FROM testcases WHERE exported == 'yes'"
        cur.execute(select)
        num = cur.fetchone()
        conn.close()
        assert num[0] == 13
Esempio n. 2
0
 def test_exported_all(self, tmpdir):
     orig_db_file = os.path.join(conf.DATA_PATH, "workitems_ids.sqlite3")
     db_file = os.path.join(str(tmpdir), "workitems_copy.sqlite3")
     shutil.copy(orig_db_file, db_file)
     dbtools.mark_exported_sqlite(db_file)
     conn = dbtools._open_sqlite(db_file)
     cur = conn.cursor()
     select = "SELECT count(*) FROM testcases WHERE exported == 'yes'"
     cur.execute(select)
     num = cur.fetchone()
     conn.close()
     assert num[0] == 13
Esempio n. 3
0
 def test_testrun_invalid_db(self):
     db_file = os.path.join(conf.DATA_PATH, "ostriz.json")
     conn = dbtools._open_sqlite(db_file)
     testrun_id = dbtools._get_testrun_from_sqlite(conn)
     assert testrun_id is None
Esempio n. 4
0
 def test_open_nonexistent(self):
     db_file = "nonexistent"
     with pytest.raises(Dump2PolarionException) as excinfo:
         dbtools._open_sqlite(db_file)
     assert "No such file or directory" in str(excinfo.value)
Esempio n. 5
0
 def test_testrun_id_exported(self):
     db_file = os.path.join(conf.DATA_PATH, "workitems_ids.sqlite3")
     conn = dbtools._open_sqlite(db_file)
     testrun_id = dbtools._get_testrun_from_sqlite(conn)
     assert testrun_id == "5_8_0_17"