Example #1
0
 def test_spinner_emits_signals(self):
     from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
     win = get_test_window_purchaseview()
     self._p()
     # get the view
     view = win.get_data("view")
     # ensure "purchase-needs-spinner" signals are send
     signal_mock = Mock()
     view.connect("purchase-needs-spinner", signal_mock)
     view.wk.webkit.load_uri("http://www.ubuntu.com/")
     self._p()
     self.assertTrue(signal_mock.called)
     # run another one
     win.destroy()
Example #2
0
 def test_spinner_emits_signals(self):
     from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
     win = get_test_window_purchaseview()
     self._p()
     # get the view
     view = win.get_data("view")
     # ensure "purchase-needs-spinner" signals are send
     signal_mock = Mock()
     view.connect("purchase-needs-spinner", signal_mock)
     view.wk.webkit.load_uri("http://www.ubuntu.com/")
     self._p()
     self.assertTrue(signal_mock.called)
     # run another one
     win.destroy()
Example #3
0
 def test_purchase_view_tos(self):
     from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
     win = get_test_window_purchaseview()
     view = win.get_data("view")
     # install the mock
     mock_config = Mock()
     mock_config.has_option.return_value = False
     mock_config.getboolean.return_value = False
     view.config = mock_config
     func = "softwarecenter.ui.gtk3.views.purchaseview.show_accept_tos_dialog"
     with patch(func) as mock_func:
         mock_func.return_value = False
         res = view.initiate_purchase(None, None)
         self.assertFalse(res)
         self.assertTrue(mock_func.called)
     win.destroy()
Example #4
0
 def test_purchase_view_tos(self):
     from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
     win = get_test_window_purchaseview()
     view = win.get_data("view")
     # install the mock
     mock_config = Mock()
     mock_config.has_option.return_value = False
     mock_config.getboolean.return_value = False
     view.config = mock_config
     func = "softwarecenter.ui.gtk3.views.purchaseview.show_accept_tos_dialog"
     with patch(func) as mock_func:
         mock_func.return_value = False
         res = view.initiate_purchase(None, None)
         self.assertFalse(res)
         self.assertTrue(mock_func.called)
     win.destroy()
Example #5
0
    def test_purchase_view_log_cleaner(self):
        import softwarecenter.ui.gtk3.views.purchaseview
        from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
        win = get_test_window_purchaseview()
        self._p()
        # get the view
        view = win.get_data("view")
        # install the mock
        softwarecenter.ui.gtk3.views.purchaseview.LOG = mock = Mock()
        # run a "harmless" log message and ensure its logged normally
        view.wk.webkit.execute_script('console.log("foo")')
        self.assertTrue("foo" in mock.debug.call_args[0][0])
        mock.reset_mock()

        # run a message that contains token info
        s = 'http://sca.razorgirl.info/subscriptions/19077/checkout_complete/ @10: {"token_key": "hiddenXXXXXXXXXX", "consumer_secret": "hiddenXXXXXXXXXXXX", "api_version": 2.0, "subscription_id": 19077, "consumer_key": "rKhNPBw", "token_secret": "hiddenXXXXXXXXXXXXXXX"}'
        view.wk.webkit.execute_script("console.log('%s')" % s)
        self.assertTrue("skipping" in mock.debug.call_args[0][0])
        self.assertFalse("consumer_secret" in mock.debug.call_args[0][0])
        mock.reset_mock()

        # run another one
        win.destroy()
Example #6
0
    def test_purchase_view_log_cleaner(self):
        import softwarecenter.ui.gtk3.views.purchaseview
        from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
        win = get_test_window_purchaseview()
        self._p()
        # get the view
        view = win.get_data("view")
        # install the mock
        softwarecenter.ui.gtk3.views.purchaseview.LOG = mock = Mock()
        # run a "harmless" log message and ensure its logged normally
        view.wk.webkit.execute_script('console.log("foo")')
        self.assertTrue("foo" in mock.debug.call_args[0][0])
        mock.reset_mock()

        # run a message that contains token info
        s = 'http://sca.razorgirl.info/subscriptions/19077/checkout_complete/ @10: {"token_key": "hiddenXXXXXXXXXX", "consumer_secret": "hiddenXXXXXXXXXXXX", "api_version": 2.0, "subscription_id": 19077, "consumer_key": "rKhNPBw", "token_secret": "hiddenXXXXXXXXXXXXXXX"}'
        view.wk.webkit.execute_script("console.log('%s')" % s)
        self.assertTrue("skipping" in mock.debug.call_args[0][0])
        self.assertFalse("consumer_secret" in mock.debug.call_args[0][0])
        mock.reset_mock()

        # run another one
        win.destroy()
Example #7
0
 def test_purchaseview(self):
     from softwarecenter.ui.gtk3.views.purchaseview import get_test_window_purchaseview
     win = get_test_window_purchaseview()
     GObject.timeout_add(TIMEOUT, lambda: win.destroy())
     Gtk.main()