def test_attach_subscription_task_success(self, environ_get):
     """Test the AttachSubscriptionTask - success."""
     rhsm_attach_proxy = Mock()
     task = AttachSubscriptionTask(rhsm_attach_proxy=rhsm_attach_proxy,
                                   sla="foo_sla")
     task.run()
     rhsm_attach_proxy.AutoAttach.assert_called_once_with(
         "foo_sla", {}, "en_US.UTF-8")
 def test_attach_subscription_task_failure(self, environ_get):
     """Test the AttachSubscriptionTask - failure."""
     rhsm_attach_proxy = Mock()
     # raise DBusError with error message in JSON
     json_error = '{"message": "Failed to attach subscription."}'
     rhsm_attach_proxy.AutoAttach.side_effect = DBusError(json_error)
     task = AttachSubscriptionTask(rhsm_attach_proxy=rhsm_attach_proxy,
                                   sla="foo_sla")
     with self.assertRaises(SubscriptionError):
         task.run()
     rhsm_attach_proxy.AutoAttach.assert_called_once_with(
         "foo_sla", {}, "en_US.UTF-8")