Exemple #1
0
	def test_performVerb(self):
		flt = [random.randint(0,100000) for x in xrange(NRDIMS * 2)]
		df = DrillForm()
		res = df.performVerb(0, 1, \
			df.hierStr2List(DEFHIER),\
			flt,\
			VERBDRILL, 0, 0,'',ANONYMOUS)
		assert repr(res[4]) == repr(flt)
Exemple #2
0
	def test_renderTable(self):
		#includes testing sums match up
		#includes runWorkers
		def lookup(html, row, col):
			assert row < 10
			assert col < 10
			start = res.find('<td id="%d_%d">' % (row, col))
			end = res.find('</td>', start)
			return float(res[start+13:end])
			
		R = 3
		C = 6
		df = DrillForm()
		res = df.renderTable(0, 1, 
			[0, 24087, 0, 15, 0, 25, 0, 50, 0, 15, 1, 1, 0, 4],
			((0, 'all time', 0, 26, 0), 
				(2006, 'time_2005', 3, 14, 1), 
				(2007, 'time_2006', 15, 26, 1)),
			((0L, 'all region', 0L, 15L, 0L), 
				(1L, 'region_0', 6L, 7L, 1L), 
				(2L, 'region_1', 8L, 9L, 1L), 
				(3L, 'region_2', 10L, 11L, 1L),
				(4L, 'region_3', 12L, 13L, 1L),
				(5L, 'region_4', 14L, 15L, 1L)))
			
		#don't forget to sync with gen.py !!!
		#all_time = sum(time_2005) 
		#same for other cols
		for c in xrange(C):
			col = map(lambda x: lookup(res, x, c), xrange(R))
			scol = sum(col[1:])
			assert (col[0] - scol) / col[0] < 0.01
		
		#all region = sum(regions)
		#same for other rows
		for r in xrange(R):
			row = map(lambda x: lookup(res, 0, x), xrange(C))
			srow = sum(row[1:])
			
			assert (row[0] - srow) / row[0] < 0.01
Exemple #3
0
	def test_hiers(self):
		df = DrillForm()
		res = df.hiers()
		assert res.find('javascript:iframedrill') != -1
		assert res.find('dtree.css') != -1
		assert res.find('dtree.js') != -1
Exemple #4
0
	def test_default(self):
		df = DrillForm()
		res = df.defaultNoSecurity('a')
		assert len(res) > 100