1

Is there a way to change the PLONE_SITE_ID from its default at plone.app.testing.interfaces without modifying the source code?

I'm using Plone 4 with several custom products, and plone.app.testing (4.0.2) with relative success. In my custom products, there are several instances where there are hardcoded physical paths to locate objects when performing catalog searches (e.g., my site root is 'mySiteID', so several custom queries use path=/mySiteID/folder1/etc.. to do catalog searches).

The problem is that the site root in the Plone instance that plone.app.testing configures (PLONE_FIXTURE) is PLONE_SITE_ID = 'plone'. Therefore, any objects that I add in my tests always have /plone as the root rather than /mySiteID and my tests break. I can fix this problem by changing the defined value in the interface but this seems like an ugly hack.

4

2 に答える 2

1

どうしても必要な場合、id にモンキーパッチを適用できます。ビルドアウトで、テスト ランナー部分の一部としてこれを行います。

[test]
# ...
initialization =
    import plone.app.testing.interfaces
    plone.app.testing.interfaces = 'mySiteID'
于 2012-10-24T20:45:12.147 に答える