Exemple #1
0
 def test_cmp(self):
   x = U.idict(Foo = 42, Bar = 37)
   y = U.idict(Foo = 42, Bar = 37)
   z = U.idict(Foo = 42, Bar = 99)
   self.assertGreater(z, x)
   self.assertGreaterEqual(z, y)
   self.assertLess(y, z)
   self.assertLessEqual(x, y)
Exemple #2
0
 def test_copy(self):
   x = U.idict(Foo = 42, Bar = 37)
   y = x.copy()
   self.assertIsInstance(y, U.idict)
   self.assertEqual(x, y)
   del x['foo']
   self.assertNotEqual(x, y)
Exemple #3
0
 def test_len(self):
   x = U.idict()
   self.assertEqual(len(x), 0)
   x['Foo'] = 42; x['Bar'] = 37
   self.assertEqual(len(x), 2)
   del x['foo']
   self.assertEqual(len(x), 1)
Exemple #4
0
 def test_repr(self):
     x = H.Request(body="<body>")
     y = [("method", "GET"), ("uri", H.URI("/")), ("version", "HTTP/1.1"),
          ("headers", U.idict()), ("body", (b"<body>", )), ("env", {})]
     self.assertEqual(
         repr(x),
         "Request({})".format(", ".join("{} = {}".format(k, repr(v))
                                        for (k, v) in y)))
Exemple #5
0
 def test_init_data_str(self):
     x = H.Response("<body>")
     self.assertEqual(
         dict(x.iteritems()),
         dict(version="HTTP/1.1",
              status=200,
              reason="OK",
              headers=U.idict(),
              body=(b"<body>", )))
Exemple #6
0
 def test_init_data_int(self):
     x = H.Response(500)
     self.assertEqual(
         dict(x.iteritems()),
         dict(version="HTTP/1.1",
              status=500,
              reason="Internal Server Error",
              headers=U.idict(),
              body=(b"", )))
Exemple #7
0
 def test_init_data_tuple(self):
     x = H.Response((404, dict(Foo="bar"), "<body>"))
     self.assertEqual(
         dict(x.iteritems()),
         dict(version="HTTP/1.1",
              status=404,
              reason="Not Found",
              headers=U.idict(Foo="bar"),
              body=(b"<body>", )))
Exemple #8
0
 def test_init_empty(self):
     x = H.Request()
     self.assertEqual(
         dict(x.iteritems()),  # also tests iteritems
         dict(method="GET",
              uri="/",
              version="HTTP/1.1",
              headers=U.idict(),
              body=(b"", ),
              env={}))
Exemple #9
0
 def test_init_kwds(self):
     x = H.Request(method="POST",
                   uri="/foo",
                   headers=dict(Foo="bar"),
                   body="<body>")
     self.assertEqual(
         dict(x.iteritems()),
         dict(method="POST",
              uri="/foo",
              version="HTTP/1.1",
              headers=U.idict(Foo="bar"),
              body=(b"<body>", ),
              env={}))
Exemple #10
0
 def test_eq(self):
   x = U.idict(Foo = 42, Bar = 37)
   y = U.idict(Foo = 42, Bar = 37)
   z = U.idict(Foo = 42, Bar = 99)
   self.assertEqual(x, y)
   self.assertNotEqual(x, z)
Exemple #11
0
 def test_iteritems_lower(self):
   x = U.idict(Foo = 42, Bar = 37)
   y = x.iteritems_lower()
   self.assertIsInstance(y, type(x for x in []))
   self.assertEqual(sorted(y), [("bar", 37), ("foo", 42)])
Exemple #12
0
 def test_iter(self):
   x = U.idict(Foo = 42, Bar = 37)
   y = iter(x)
   self.assertIsInstance(y, type(x for x in []))
   self.assertEqual(sorted(y), ["Bar", "Foo"])
Exemple #13
0
 def test_del(self):
   x = U.idict(Foo = 42); del x['foo']
   self.assertEqual(list(x.values()), [])
Exemple #14
0
 def test_get(self):
   x = U.idict(Foo = 42, Bar = 37)
   self.assertEqual(x['Foo'], 42)
   self.assertEqual(x['foo'], 42)
   self.assertEqual(x['fOO'], 42)
   self.assertEqual(x['Bar'], 37)
Exemple #15
0
 def test_set(self):
   x = U.idict(); x['Foo'] = 42; x['Bar'] = 37
   self.assertEqual(x['Foo'], 42)
   self.assertEqual(x['foo'], 42)
   self.assertEqual(x['fOO'], 42)
   self.assertEqual(x['Bar'], 37)
Exemple #16
0
 def test_repr(self):
   x = U.idict(x = 42)
   self.assertEqual(str(x), "idict({'x': 42})")
Exemple #17
0
 def test_init_headers(self):
     x = H.Request(headers=dict(x=37, y=42))
     self.assertIsInstance(x.headers, U.idict)
     self.assertEqual(x.headers, U.idict(x=37, Y=42))