예제 #1
0
파일: content.py 프로젝트: robgil/pulsar
 def test_remove_valueerror(self):
     root = wsgi.AsyncString()
     child1 = wsgi.AsyncString()
     self.assertEqual(len(root.children), 0)
     root.remove(child1)
     self.assertEqual(len(root.children), 0)
     child1.append_to(root)
     self.assertEqual(len(root.children), 1)
     self.assertEqual(child1.parent, root)
예제 #2
0
파일: content.py 프로젝트: robgil/pulsar
 def test_append(self):
     root = wsgi.AsyncString()
     child1 = wsgi.AsyncString()
     child2 = wsgi.AsyncString()
     root.append(child1)
     self.assertEqual(child1.parent, root)
     self.assertEqual(len(root.children), 1)
     root.prepend(child2)
     self.assertEqual(child2.parent, root)
     self.assertEqual(len(root.children), 2)
예제 #3
0
파일: content.py 프로젝트: robgil/pulsar
 def test_append_parent(self):
     root = wsgi.AsyncString()
     child1 = wsgi.AsyncString()
     child2 = wsgi.AsyncString()
     root.append(child1)
     root.append(child2)
     self.assertEqual(len(root.children), 2)
     child1.append(root)
     self.assertEqual(child1.parent, None)
     self.assertEqual(root.parent, child1)
     self.assertEqual(len(root.children), 1)
     self.assertEqual(len(child1.children), 1)
예제 #4
0
파일: content.py 프로젝트: robgil/pulsar
 def test_change_parent(self):
     root = wsgi.AsyncString()
     child1 = wsgi.AsyncString()
     child2 = wsgi.AsyncString()
     child3 = wsgi.AsyncString()
     root.append(child1)
     child1.append(child2)
     child1.append(child3)
     self.assertEqual(len(root.children), 1)
     self.assertEqual(len(child1.children), 2)
     root.append(child3)
     self.assertEqual(len(root.children), 2)
     self.assertEqual(len(child1.children), 1)
예제 #5
0
파일: content.py 프로젝트: robgil/pulsar
 def test_append_parent_with_parent(self):
     root = wsgi.AsyncString()
     child1 = wsgi.AsyncString()
     child2 = wsgi.AsyncString()
     child3 = wsgi.AsyncString()
     root.append(child1)
     child1.append(child2)
     child1.append(child3)
     self.assertEqual(len(root.children), 1)
     self.assertEqual(len(child1.children), 2)
     child2.append(child1)
     self.assertEqual(len(root.children), 1)
     self.assertEqual(root.children[0], child2)
     self.assertEqual(len(child2.children), 1)
     self.assertEqual(child1.parent, child2)
     self.assertEqual(child2.parent, root)
예제 #6
0
파일: content.py 프로젝트: robgil/pulsar
 def test_json_with_async_string(self):
     astr = wsgi.AsyncString('ciao')
     response = wsgi.Json({'bla': astr})
     self.assertEqual(len(response.children), 1)
     self.assertEqual(response.content_type,
                      'application/json; charset=utf-8')
     self.assertEqual(response.render(), json.dumps({'bla': 'ciao'}))
예제 #7
0
파일: content.py 프로젝트: robgil/pulsar
 def test_json_with_async_string2(self):
     d = Future()
     astr = wsgi.AsyncString(d)
     response = wsgi.Json({'bla': astr})
     self.assertEqual(len(response.children), 1)
     result = response.render()
     self.assertIsInstance(result, Future)
     d.set_result('ciao')
     result = yield result
     self.assertEqual(result, json.dumps({'bla': 'ciao'}))
예제 #8
0
 def test_json_with_async_string2(self):
     d = Deferred()
     astr = wsgi.AsyncString(d)
     response = wsgi.Json({'bla': astr})
     self.assertEqual(len(response.children), 1)
     result = response.render()
     self.assertIsInstance(result, Deferred)
     d.callback('ciao')
     result = yield result
     self.assertEqual(result, json.dumps({'bla': 'ciao'}))
예제 #9
0
파일: content.py 프로젝트: robgil/pulsar
 def test_string(self):
     a = wsgi.AsyncString('Hello')
     self.assertEqual(a.render(), 'Hello')
     self.assertRaises(RuntimeError, a.render)
예제 #10
0
파일: content.py 프로젝트: robgil/pulsar
 def test_append_self(self):
     root = wsgi.AsyncString()
     self.assertEqual(root.parent, None)
     root.append(root)
     self.assertEqual(root.parent, None)
     self.assertEqual(len(root.children), 0)