예제 #1
0
파일: calls.py 프로젝트: notoriousno/shiji
 def render_GET(self, request):
     """
     Simple PING call, that echoes back the client's supplied timestamp.
     
     URL Path Arguments:
     ----------
         timestamp (int) - Client supplied UNIX timestamp.
     
     
     Returns
     ---------
     
         Success:
             (unicode) - String echoing parameters.
     
         Failure:
             Returns a JSON error dictionary.
     
     """
     timestamp =  int(self.url_matches["timestamp"])
     
     if request.api_mode == "prod":
         mode_string = "I'm production baby!"
     elif request.api_mode == "test":
         mode_string = "I'm in testing mode. :("
     else:
         mode_string = "I have no clue what mode I'm in."
     
     response = "PONG! Right back at ya. %s " % mode_string
     response = response + " (Timestamp Val: %d) " % timestamp
     response = response + "(API: %s, Version: %s, Mode: %s)" % (request.api_name,
                                                                 request.api_version,
                                                                 request.api_mode)
     webapi.write_json(request, response)
예제 #2
0
파일: calls.py 프로젝트: williamsjj/shiji
    def render_GET(self, request):
        """
        Simple PING call, that echoes back the client's supplied timestamp.
        
        URL Path Arguments:
        ----------
            timestamp (int) - Client supplied UNIX timestamp.
        
        
        Returns
        ---------
        
            Success:
                (unicode) - String echoing parameters.
        
            Failure:
                Returns a JSON error dictionary.
        
        """
        timestamp = int(self.url_matches["timestamp"])

        if request.api_mode == "prod":
            mode_string = "I'm production baby!"
        elif request.api_mode == "test":
            mode_string = "I'm in testing mode. :("
        else:
            mode_string = "I have no clue what mode I'm in."

        response = "PONG! Right back at ya. %s " % mode_string
        response = response + " (Timestamp Val: %d) " % timestamp
        response = response + "(API: %s, Version: %s, Mode: %s)" % (
            request.api_name, request.api_version, request.api_mode)
        webapi.write_json(request, response)
예제 #3
0
 def test_write_json(self):
     "Validate write_json outputs JSON & sets content length"
 
     test_request = DummyRequest()
     test_obj = {"test_key": "test_value"}
     webapi.write_json(test_request, test_obj)
 
     self.assertEquals(test_request.getAllHeaders()["Content-Length"], len(json.dumps(test_obj)))
     self.assertEquals(test_request.content.getvalue(), json.dumps(test_obj))
예제 #4
0
    def test_write_json(self):
        "Validate write_json outputs JSON & sets content length"

        test_request = DummyRequest()
        test_obj = {"test_key": "test_value"}
        webapi.write_json(test_request, test_obj)

        self.assertEquals(test_request.getAllHeaders()["Content-Length"],
                          len(json.dumps(test_obj)))
        self.assertEquals(test_request.content.getvalue(),
                          json.dumps(test_obj))
예제 #5
0
 def render_GET(self, request):
     
     if request.api_mode == "prod":
         mode_string = "I'm production baby!"
     elif request.api_mode == "test":
         mode_string = "I'm in testing mode. :("
     else:
         mode_string = "I have no clue what mode I'm in."
     webapi.write_json(request, "POLLS PONG! Right back at ya. %s (API: %s, Version: %s, Mode: %s)" % (mode_string,
                                                                                                       request.api_name,
                                                                                                       request.api_version,
                                                                                                       request.api_mode))