예제 #1
0
 def test_create_fail(self):
     """
     when the session doesn't have a get method, a
     ValueError should be raised
     """
     with self.assertRaises(ValueError):
         fake_session = None
         backend = session_backend(fake_session)
예제 #2
0
 def test_get_empty(self):
     session = MockSession("", 200)
     backend = session_backend(session)
     text = backend("http://www.empty-example.com")
     self.assertIsNone(text)
예제 #3
0
 def test_get_not_ok(self):
     session = MockSession("<html></html>", 404)
     backend = session_backend(session)
     text = backend("http://www.bad-example.com")
     self.assertIsNone(text)
예제 #4
0
 def test_get_success(self):
     session = MockSession("<html></html>", 200)
     backend = session_backend(session)
     text = backend("http://www.example.com")
     self.assertIsNotNone(text)
예제 #5
0
 def test_create_success(self):
     session = requests.Session()
     get = session_backend(session)
     self.assertIsInstance(get, types.FunctionType)