Importing deck using python

I am working on an addon, for anki, which requires me to import a new deck using its python API. I found the function called test_apkg (anki/ at 627f910635893f8205f7004572ba2ac7f3d987b8 · ankitects/anki · GitHub)
which seems to have parts which do that. I tried implementing that below, I am getting no errors, however the deck does not get imported. How do I make my testFunction() import a deck for anki?

from aqt import mw
from aqt.utils import showInfo, qconnect
from aqt.qt import *

from anki.importing import *

import os

from anki.collection import Collection as aopen

#from anki.pylib.tests.shared import getEmptyCol

from .shared import getEmptyCol

def testFunction() -> None:

    file = "flashcards.apkg"

    col = getEmptyCol()

    apkg = r"path_to_file/flashcards.apkg"
    imp = AnkiPackageImporter(col, apkg)

# create a new menu item, "test"
action = QAction("Import", mw)
# set it to call testFunction when it's clicked
qconnect(action.triggered, testFunction)
# and add it to the tools menu

Maybe imp.log will reveal something.