Пример #1
0
	def setup(self):
		WorkoutCategoryModel("Running", True).save(commit=False)
		WorkoutCategoryModel("Fitness", False).save()
		self.running_workout_category = WorkoutCategoryModel.get_by_id(1)
		self.fitness_workout_category = WorkoutCategoryModel.get_by_id(2)
		GoalCategoryModel("Cumulative distance", "km", 1).save(commit=False)
		GoalCategoryModel("Number of workouts", "#", 1).save(commit=False)
		GoalCategoryModel("Number of workouts", "#", 2).save(commit=False)
		GoalCategoryModel("Cumulative climb", "m", 1).save(commit=False)
		GoalCategoryModel("Weight loss", "kg", None).save()
		self.cumulative_distance_goal_category = GoalCategoryModel.get_by_id(1)
		self.num_of_running_workouts_goal_category = GoalCategoryModel.get_by_id(2)
		self.num_of_fitness_workouts_goal_category = GoalCategoryModel.get_by_id(3)
		self.cumulative_climb_goal_category = GoalCategoryModel.get_by_id(4)
		self.weight_loss_goal_category = GoalCategoryModel.get_by_id(5)
		two_days_ago = dt.datetime.utcnow() - dt.timedelta(days=2)
		two_days_from_now = dt.datetime.utcnow() + dt.timedelta(days=2)
		GoalModel(self.profile_id, self.cumulative_distance_goal_category, two_days_ago, two_days_from_now, 0, 100, 0).save(commit=False)
		GoalModel(self.profile_id, self.num_of_running_workouts_goal_category, two_days_ago, two_days_from_now, 0, 10, 0).save(commit=False)
		GoalModel(self.profile_id, self.num_of_fitness_workouts_goal_category, two_days_ago, two_days_from_now, 0, 10, 0).save(commit=False)
		GoalModel(self.profile_id, self.cumulative_climb_goal_category, two_days_ago, two_days_from_now, 0, 500, 0).save(commit=False)
		GoalModel(self.profile_id, self.weight_loss_goal_category, two_days_ago, two_days_from_now, 80, 70, 78).save()
		self.cumulative_distance_goal = GoalModel.get_by_id(1)
		self.running_workouts_goal = GoalModel.get_by_id(2)
		self.fitness_workouts_goal = GoalModel.get_by_id(3)
		self.cumulative_climb_goal = GoalModel.get_by_id(4)
		self.weight_loss_goal = GoalModel.get_by_id(5)
Пример #2
0
	def test_get_by_id(self):
		category = GoalCategoryModel.get_by_id(1)
		new_goal = GoalModel(1, category)
		new_goal.save()
		retrieved_goal = GoalModel.get_by_id(new_goal.id)
		assert(retrieved_goal == new_goal)