def test_mine(self): user_info = {'username': '******', 'email': '[email protected]', 'password': '******'} new_user = User.objects.create_user(**user_info) user_profile = UserProfile() user_profile.user = new_user scan = ScanningEquipment.objects.get_or_create(name="Oil Lamp", modifier=0.2, image='icons/Scan/Oil Lamp.png', price=1, description="It won't allow you to see much but it's better than going in blind!", store_val=20)[0] dig = DiggingEquipment.objects.get_or_create(name='Spoon', modifier=0.3, time_modifier=5, image='icons/Tools/Spoon.png', price=1, description="What am I supposed to do with this?", store_val=30)[0] move = Vehicle.objects.get_or_create(name='Boots', modifier=10, image='icons/Vehicle/Boots.png', price=1, description="Two boots is better than no boots!")[0] user_profile.equipment = scan user_profile.tool = dig user_profile.vehicle = move accuracy = 0.2 max_gold = 100 gen = yieldgen.ScotlandQuadraticYieldGenerator(depth=10, max=max_gold, min=0) m = mine.Mine(gen, accuracy, user_profile) for block in m.blocks: self.failIf(block.cue == None) self.failIf(block.gold == None) self.failIf(block.dug == True) self.failIf((block.pos/10)>=1) self.failIf((block.pos/10)<=-1)
def test_user_profile_data(self): """ Check if UserProfile object is created with appropriate data """ user_info = {'username': '******', 'email': '*****@*****.**', 'password': '******'} new_user = User.objects.create_user(**user_info) user_profile = UserProfile() user_profile.user = new_user scan = ScanningEquipment.objects.get_or_create(name="Oil Lamp", modifier=0.2, image='icons/Scan/Oil Lamp.png', price=1, description="It won't allow you to see much but it's better than going in blind!", store_val=20)[0] dig = DiggingEquipment.objects.get_or_create(name='Spoon', modifier=0.3, time_modifier=5, image='icons/Tools/Spoon.png', price=1, description="What am I supposed to do with this?", store_val=30)[0] move = Vehicle.objects.get_or_create(name='Boots', modifier=10, image='icons/Vehicle/Boots.png', price=1, description="Two boots is better than no boots!")[0] user_profile.equipment = scan user_profile.tool = dig user_profile.vehicle = move self.assertEqual(user_profile.user.username, 'guybrush') self.assertEqual(new_user.email, '*****@*****.**') self.failUnless(new_user.check_password('secret')) self.failIf(not new_user.is_active) self.failIf(not user_profile.equipment) self.failIf(not user_profile.tool) self.failIf(not user_profile.vehicle) self.assertEqual(user_profile.gold, 100) self.assertEqual(user_profile.games_played, 0) self.assertEqual(user_profile.game_overs, 0) self.assertEqual(user_profile.mines, 0)
def add_new_profile(user, response, *args, **kwargs): try: profile = UserProfile.objects.get(user=user) except UserProfile.DoesNotExist: profile = UserProfile(user=user) profile.equipment = ScanningEquipment.objects.get(pk=1) profile.vehicle = Vehicle.objects.get(pk=1) profile.tool = DiggingEquipment.objects.get(pk=1) profile.save()