Beispiel #1
0
 def test_decorators(self):
     turtle = graph.serialize(format='turtle')
     xml = graph.serialize(format='xml')
     view = graph
     accepts = 'text/n3;q=0.5, text/turtle;q=0.9'
     decorator = Decorator()
     response = decorator.output(view, accepts)
     self.assertEqual(turtle, response.get_data())
     self.assertEqual('text/turtle; charset=utf-8',
                      response.headers['content-type'])
     self.assertEqual('Accept', response.headers['vary'])
     # use the decorator
     decoratee = lambda *args: view
     decorated = decorator.decorate(decoratee)
     response = decorated()
     self.assertEqual(xml, response.get_data())
     self.assertEqual('application/rdf+xml',
                      response.headers['content-type'])
     self.assertEqual('Accept', response.headers['vary'])
     decorated = decorator(decoratee)
     response = decorated()
     self.assertEqual(xml, response.get_data())
     self.assertEqual('application/rdf+xml',
                      response.headers['content-type'])
     self.assertEqual('Accept', response.headers['vary'])
Beispiel #2
0
 def test_weird_graph(self):
     # If an object somehow sneaks past get_graph/is_graph
     # test that replace_graph doesn't crash about it
     decorator = Decorator()
     test_str = 'This is a test string'
     accepts = 'text/n3;q=0.5, text/turtle;q=0.9'
     response = decorator.replace_graph(test_str, 'wrong')
     self.assertEqual(test_str, response)
Beispiel #3
0
	def test_weird_graph(self):
		# If an object somehow sneaks past get_graph/is_graph
		# test that replace_graph doesn't crash about it
		decorator = Decorator()
		test_str = 'This is a test string'
		accepts = 'text/n3;q=0.5, text/turtle;q=0.9'
		response = decorator.replace_graph(test_str, 'wrong')
		self.assertEqual(test_str, response)
Beispiel #4
0
	def test_decorators(self):
		turtle = graph.serialize(format='turtle')
		xml = graph.serialize(format='xml')
		view = graph
		accepts = 'text/n3;q=0.5, text/turtle;q=0.9'
		decorator = Decorator()
		response = decorator.output(view, accepts)
		self.assertEqual(turtle, response.get_data())
		self.assertEqual('text/turtle; charset=utf-8', response.headers['content-type'])
		# use the decorator
		decoratee = lambda *args: view
		decorated = decorator.decorate(decoratee)
		response = decorated()
		self.assertEqual(xml, response.get_data())
		self.assertEqual('application/rdf+xml', response.headers['content-type'])
		decorated = decorator(decoratee)
		response = decorated()
		self.assertEqual(xml, response.get_data())
		self.assertEqual('application/rdf+xml', response.headers['content-type'])