def generate_efforts(n=10, tags=["a","b"], times=[1,2], default_swept_area=lambda: 1, default_hours_fished=lambda: 1):

	efforts = []

	# Get gears.
	gears = generate_gears()

	# Get cells.
	cells = habitat_util.generate_cells(n/2 + 1)

	for i in range(n):
		cell_i = cells[i % len(cells)]
		gear_i = gears[i % len(gears)]
		time = times[i % len(times)]
		o = Effort(
				cell = cell_i,
				time = time,
				gear = gear_i,
				tag = tags[i % len(tags)],
				swept_area = default_swept_area(),
				hours_fished = default_hours_fished() 
				)

		efforts.append(util_registry.get_or_register_object(o,id_func=lambda obj: id(obj)))

	return efforts
	def test(self):

		habitat_types = habitat_util.generate_habitat_types()
		habitats = habitat_util.generate_habitats(10)
		cells = habitat_util.generate_cells(10)

		self.failUnless(True)
def generate_results(n=10, tags=["a", "b"]):

	results = []

	# Get gears.
	gears = fishing_util.generate_gears()

	# Get features.
	features = habitat_util.generate_features(n)

	# Get cells.
	cells = habitat_util.generate_cells(n/2 + 1)

	for i in range(n):
		cell_i = cells[i % len(cells)]
		gear_i = gears[i % len(gears)]
		feature_i = features[i % len(features)]
		o = Result(
				time = i,
				cell = cell_i,
				habitat_type = cell_i.habitats[0].habitat_type,
				gear = gear_i,
				feature = feature_i,
				field = "field_%s" % i,
				tag = tags[i % len(tags)],
				value = i
				)

		results.append(util_registry.get_or_register_object(o,id_func=lambda obj: id(obj)))

	return results
	def __init__(self, num_cells=10):
		self.cells = {}

		n = 0
		for c in habitat_util.generate_cells(num_cells, default_area = lambda: (1000.0 * 100)**2 ):
			c.id = n
			c.type='km100'
			self.cells[n] = c
			n += 1		
	def test(self):
		s = self.session

		# Drop/Create tables.
		sa_metadata.metadata.drop_all(s.bind)
		sa_metadata.metadata.create_all(s.bind)
		
		# Generate test cell
		cell = habitat_util.generate_cells(1).pop()

		# Add to the session and commit.
		s.merge(cell)
		s.commit()

		cells = s.query(Cell).all()

		self.failUnless(True)