Esempio n. 1
0
 def execute(self, request_object):
     try:
         result = self.repo.create_comment(request_object.to_dict())
         return ResponseSuccess(result)
     except Exception as exc:
         return ResponseFailure.build_system_error("{}: {}".format(
             exc.__class__.__name__, "{}".format(exc)))
Esempio n. 2
0
 def execute(self, request_object):
     try:
         result = self.repo.get_post_list()
         return ResponseSuccess(result)
     except Exception as exc:
         return ResponseFailure.build_system_error("{}: {}".format(
             exc.__class__.__name__, "{}".format(exc)))
 def execute(self, request):
     try:
         users = self.repo.list()
         return ResponseSuccess(users)
     except Exception as exc:
         return ResponseFailure.build_system_error("{}: {}".format(
             exc.__class__.__name__, "{}".format(exc)))
Esempio n. 4
0
    def execute(self, request_object):
        if not request_object:
            return ResponseFailure.build_from_invalid_request_object(
                request_object)

        try:
            result = self.repo.get_post_item(request_object.id)

            if result is None:
                return ResponseFailure.build_not_found_error("{}: {}".format(
                    "NotFoundError", "Resource not found."))

            return ResponseSuccess(result)
        except Exception as exc:
            return ResponseFailure.build_system_error("{}: {}".format(
                exc.__class__.__name__, "{}".format(exc)))
    def execute(self, request):
        email = request.email
        password = request.password

        result = self._repo.authenticate(email, password)
        return ResponseSuccess(result)
def test_response_success_has_type_and_value(response_value):
    response = ResponseSuccess(response_value)

    assert response.type == ResponseSuccess.SUCCESS
    assert response.value == response_value
def test_response_success_is_true(response_value):
    assert bool(ResponseSuccess(response_value)) is True