Example #1
0
 def test_projects(self):
   HTTPretty.register_uri(HTTPretty.GET, 
     "http://test.triv.io/",
     body="redirect",
     location="http://test.triv.io/integrated",
     status=302
   )
   
   HTTPretty.register_uri(HTTPretty.GET, 
     "http://test.triv.io/integrated",
     body=""
   )
       
   
   conn = Client(
     "test.triv.io", 
     auth_input=self.auth_input,
     cookie_path=self.cookie_path
   )
   
   HTTPretty.register_uri(HTTPretty.GET, 
     "http://test.triv.io/workspaces/",
     body='[{"title": "foo", "tables":{}}]'
   )
   
   eq_(len(conn.projects()), 1)
Example #2
0
 def test_unathorized(self):
   def request_callback(method, uri, headers):
     headers['content_type'] = "text/html"
     headers['status'] = 401
     return (
       '<html><head><title>Triv.io Beta</title></head>'
       '<body>'
       '<a href="https://github.com/login/oauth/authorize"/>'
       '</body>'
       '</html>'
     )
   
   HTTPretty.register_uri(HTTPretty.GET,
     "http://test.triv.io/",
     body=request_callback
   )
   
   HTTPretty.register_uri(HTTPretty.GET,
     "http://test.triv.io/workspaces/",
     responses=[
       HTTPretty.Response(
         body="access denied",
         status=401
       ),
       HTTPretty.Response(
         body='[]',
         content_type="application_json"
       )
       
     ]
   )
   
   HTTPretty.register_uri(HTTPretty.GET,
     "https://github.com/login/oauth/authorize",
     body="redirecting",
     status=302,
     location="http://test.triv.io/integrated"
   )
   
   # todo, create a real api-end point for logins
   HTTPretty.register_uri(HTTPretty.GET,
     "http://test.triv.io/integrated",
     body="you made it",
   )
          
   conn = Client(
     "test.triv.io", 
     auth_input=self.auth_input,
     cookie_path=self.cookie_path
   )
   conn.projects()