ThemeSiteSetup Broken In Test Setup

When trying to use the import-site-setup form of collective.themesitesetup manually in a test site, traversal to the import-site-setup form fails with the following code portal.unrestrictedTraverse(directory_string + "/@@import-site-setup”). Manually navigating to the form page in a robot framework instance of phone seems to work fine. In an attempt to get the functionality working anyway, I copied the code executed to handle the form import into the test setup. However, only top-level content is created, with all content within folders not being created.

Stepping through the calls, it seems as through the adapter query to get the content creation factory in GenericSetup.content._makeInstance returns None and so any child content which needs to be imported isn't created

Any suggestions as to why the themesitesetup behaves so differently when called from setUpPloneSite within the test site setup compared to a running Plone instance?

Unfortunately, the structure (content) import step is one of the many parts of Plone that have not get the love they would have deserve lately, so anything is possible :frowning:

So, according to your research, this adapter call only fails during setUpPloneSite, but succeeds later when the test server is running? That's surprising.

Is this Plone 4 or Plone 5? With both Dexterity and Archetypes or only Dexterity?

I don't remember anymore the details on why I ended up developing custom adapters for structure import, but you could try if including adding <include package="collective.themesitesetup" file="extras.zcml" /> helps, or even cherry-picking some adapter registration from it: https://github.com/collective/collective.themesitesetup/blob/master/src/collective/themesitesetup/extras.zcml

Plone Foundation Code of Conduct