# Path: conjureup/controllers/juju/vspheresetup/gui.py
# class VSphereSetupController(common.BaseVSphereSetupController):
#     def __init__(self):
#         self.authenticating = asyncio.Event()
# 
#     def render(self):
#         self.render_interstitial()
#         app.loop.create_task(self.login_to_vsphere())
# 
#     async def login_to_vsphere(self):
#         # Assign current datacenter
#         await app.provider.login()
#         datacenter = None
#         for dc in await app.provider.get_datacenters():
#             if dc.name == app.provider.region:
#                 datacenter = dc
#         if datacenter is None:
#             raise common.VSphereRegionError(
#                 'Unable to get info for region {}'.format(app.provider.region))
#         self.authenticating.clear()
#         self.render_setup(datacenter)
# 
#     def render_setup(self, datacenter):
#         self.view = VSphereSetupView(datacenter,
#                                      self.finish,
#                                      self.back)
#         self.view.show()
# 
#     def render_interstitial(self):
#         self.authenticating.set()
#         view = InterstitialView(title="VSphere Login Wait",
#                                 message="Logging in to VSphere. Please wait.",
#                                 event=self.authenticating)
#         view.show()
# 
#     def back(self):
#         controllers.use('providersetup').render(going_back=True)


import unittest
from unittest.mock import MagicMock, patch
from conjureup.controllers.juju.vspheresetup.gui import VSphereSetupController
#!/usr/bin/env python
#
# test vsphere configuration
#
# Copyright 2016-2017 Canonical, Ltd.





class VSphereSetupGUITestCase(unittest.TestCase):

    def setUp(self):
        self.controllers_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.common.controllers')
        self.mock_controllers = self.controllers_patcher.start()

        self.view_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.gui.VSphereSetupView')
        self.mock_view = self.view_patcher.start()
        self.render_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.gui.'
            'VSphereSetupController.render')
        self.mock_render = self.render_patcher.start()

        self.app_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.common.app')
        self.mock_app = self.app_patcher.start()
        self.mock_app.ui = MagicMock(name="app.ui")


# Path: conjureup/controllers/juju/vspheresetup/gui.py
# class VSphereSetupController(common.BaseVSphereSetupController):
#     def __init__(self):
#         self.authenticating = asyncio.Event()
# 
#     def render(self):
#         self.render_interstitial()
#         app.loop.create_task(self.login_to_vsphere())
# 
#     async def login_to_vsphere(self):
#         # Assign current datacenter
#         await app.provider.login()
#         datacenter = None
#         for dc in await app.provider.get_datacenters():
#             if dc.name == app.provider.region:
#                 datacenter = dc
#         if datacenter is None:
#             raise common.VSphereRegionError(
#                 'Unable to get info for region {}'.format(app.provider.region))
#         self.authenticating.clear()
#         self.render_setup(datacenter)
# 
#     def render_setup(self, datacenter):
#         self.view = VSphereSetupView(datacenter,
#                                      self.finish,
#                                      self.back)
#         self.view.show()
# 
#     def render_interstitial(self):
#         self.authenticating.set()
#         view = InterstitialView(title="VSphere Login Wait",
#                                 message="Logging in to VSphere. Please wait.",
#                                 event=self.authenticating)
#         view.show()
# 
#     def back(self):
#         controllers.use('providersetup').render(going_back=True)


# Path: test/controllers_juju/test_controllers_vspheresetup_gui.py
import unittest
from unittest.mock import MagicMock, patch
from conjureup.controllers.juju.vspheresetup.gui import VSphereSetupController

#!/usr/bin/env python
#
# test vsphere configuration
#
# Copyright 2016-2017 Canonical, Ltd.





class VSphereSetupGUITestCase(unittest.TestCase):

    def setUp(self):
        self.controllers_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.common.controllers')
        self.mock_controllers = self.controllers_patcher.start()

        self.view_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.gui.VSphereSetupView')
        self.mock_view = self.view_patcher.start()
        self.render_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.gui.'
            'VSphereSetupController.render')
        self.mock_render = self.render_patcher.start()

        self.app_patcher = patch(
            'conjureup.controllers.juju.vspheresetup.common.app')
        self.mock_app = self.app_patcher.start()
        self.mock_app.ui = MagicMock(name="app.ui")


        self.controller = VSphereSetupController()