From 01984d6b3f965b6224b215783a5616598516fb1e Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Tue, 26 May 2020 01:52:39 +0000
Subject: [PATCH] slapos_jio_ui_test: Add utility script to restore MailHost to
 original

When you run tests, MailHost is normally changed to DummyMailHost, this script helps you to restore, in case you want to configure your development instance as a demo site.
---
 .../extension.erp5.SlapOSUiTest.py            | 19 ++++++++++++-
 .../ERP5Site_restoreDummyMailHost.xml         | 28 +++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 master/bt5/slapos_jio_ui_test/SkinTemplateItem/portal_skins/slapos_ui_test/ERP5Site_restoreDummyMailHost.xml

diff --git a/master/bt5/slapos_jio_ui_test/ExtensionTemplateItem/portal_components/extension.erp5.SlapOSUiTest.py b/master/bt5/slapos_jio_ui_test/ExtensionTemplateItem/portal_components/extension.erp5.SlapOSUiTest.py
index 8a6ea33e2..e0fd88a60 100644
--- a/master/bt5/slapos_jio_ui_test/ExtensionTemplateItem/portal_components/extension.erp5.SlapOSUiTest.py
+++ b/master/bt5/slapos_jio_ui_test/ExtensionTemplateItem/portal_components/extension.erp5.SlapOSUiTest.py
@@ -1,3 +1,6 @@
+from ExtensionClass import pmc_init_of
+from Products.ERP5Type.tests.utils import DummyMailHostMixin
+
 from AccessControl.SecurityManagement import getSecurityManager
 from AccessControl.SecurityManagement import setSecurityManager
 from AccessControl.SecurityManagement import newSecurityManager
@@ -93,4 +96,18 @@ def Computer_simulateSlapgridFormat(self, partition_count=10):
     return portal.portal_slap.loadComputerConfigurationFromXML(
         xml_marshaller.xml_marshaller.dumps(computer_dict))
   finally:
-    setSecurityManager(sm)
\ No newline at end of file
+    setSecurityManager(sm)
+
+
+def restoreDummyMailHost(self):
+  """Restore the replacement of Original Mail Host by Dummy Mail Host.
+
+    Copied & pasted from ERP5TypeTestCaseMixin._restoreMailHost
+  """
+  mailhost = self.getPortalObject().MailHost
+  cls = mailhost.__class__
+  if cls.__bases__[0] is DummyMailHostMixin:
+    cls.__bases__ = cls.__bases__[1:]
+  pmc_init_of(cls)
+
+  return True
diff --git a/master/bt5/slapos_jio_ui_test/SkinTemplateItem/portal_skins/slapos_ui_test/ERP5Site_restoreDummyMailHost.xml b/master/bt5/slapos_jio_ui_test/SkinTemplateItem/portal_skins/slapos_ui_test/ERP5Site_restoreDummyMailHost.xml
new file mode 100644
index 000000000..773a0f835
--- /dev/null
+++ b/master/bt5/slapos_jio_ui_test/SkinTemplateItem/portal_skins/slapos_ui_test/ERP5Site_restoreDummyMailHost.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_function</string> </key>
+            <value> <string>restoreDummyMailHost</string> </value>
+        </item>
+        <item>
+            <key> <string>_module</string> </key>
+            <value> <string>SlapOSUiTest</string> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>ERP5Site_restoreDummyMailHost</string> </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string></string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
-- 
2.30.9