def test_auto_fill_in_email(self):
     def _load_status_changed(view, status):
         if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:
             loop.quit()
     loop =  GObject.MainLoop(GObject.main_context_default())       
     webview = SoftwareCenterWebView()
     email = "foo@bar"
     webview.set_auto_insert_email(email)
     with patch.object(webview, "execute_script") as mock_execute_js:
         webview.connect("notify::load-status", _load_status_changed)
         webview.load_uri("https://login.ubuntu.com")
         loop.run()
         mock_execute_js.assert_called()
         mock_execute_js.assert_called_with(
             SoftwareCenterWebView.AUTO_FILL_EMAIL_JS % email)
    def test_auto_fill_in_email(self):
        def _load_status_changed(view, status):
            if view.get_property("load-status") == WebKit.LoadStatus.FINISHED:
                loop.quit()

        loop = GObject.MainLoop(GObject.main_context_default())
        webview = SoftwareCenterWebView()
        email = "foo@bar"
        webview.set_auto_insert_email(email)
        with patch.object(webview, "execute_script") as mock_execute_js:
            webview.connect("notify::load-status", _load_status_changed)
            webview.load_uri("https://login.ubuntu.com")
            loop.run()
            mock_execute_js.assert_called()
            mock_execute_js.assert_called_with(
                SoftwareCenterWebView.AUTO_FILL_EMAIL_JS % email)