def test_add_2(self, characters='#@'): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in range(0, 25): recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( characters=characters) recipes.append(recipe2) ingres.append(ingre) outputs.append(output) self.recipes.add_shapeless_recipe(recipe3, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i])
def test_add_2(self, characters='#@'): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in xrange(0, 25): recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe(characters=characters) recipes.append(recipe2) ingres.append(ingre) outputs.append(output) self.recipes.add_shapeless_recipe(recipe3, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i])
def test_add_3(self): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in range(0, 25): shapeless = random.choice([True, False]) if shapeless: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( ) else: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( characters='12') recipes.append(recipe2) ingres.append(ingre) outputs.append(output) if shapeless: self.recipes.add_shapeless_recipe(recipe3, output) else: self.recipes.add_recipe(recipe, ingre, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i])
def test_add_3(self): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in xrange(0, 25): shapeless = random.choice([True, False]) if shapeless: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe() else: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe(characters='12') recipes.append(recipe2) ingres.append(ingre) outputs.append(output) if shapeless: self.recipes.add_shapeless_recipe(recipe3, output) else: self.recipes.add_recipe(recipe, ingre, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i])
class CraftingTests(unittest.TestCase): current_block_id = 0 def generate_random_recipe(self, characters='#@'): recipe = [] recipe2 = [] recipe3 = [] ingre = {} for character in characters: ingre[character] = G.BLOCKS_DIR.values()[self.current_block_id] self.current_block_id += 1 if self.current_block_id >= len(G.BLOCKS_DIR.values()): self.current_block_id = 0 for i in xrange(0, 3): recipe.append(''.join(random.choice(characters) for x in xrange(3))) recipe2.append([]) for character in recipe[i]: recipe2[i].append(ingre[character]) recipe3.append(ingre[character]) return recipe, ingre, ItemStack(random.choice(G.BLOCKS_DIR.values()).id, amount=random.randint(1, 20)), recipe2, recipe3 def test_add_1(self, characters='#@'): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in xrange(0, 50): recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe(characters=characters) recipes.append(recipe2) ingres.append(ingre) outputs.append(output) self.recipes.add_recipe(recipe, ingre, output) self.assertEqual(self.recipes.nr_recipes, 50) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i]) def test_add_2(self, characters='#@'): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in xrange(0, 25): recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe(characters=characters) recipes.append(recipe2) ingres.append(ingre) outputs.append(output) self.recipes.add_shapeless_recipe(recipe3, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i]) def test_add_3(self): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in xrange(0, 25): shapeless = random.choice([True, False]) if shapeless: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe() else: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe(characters='12') recipes.append(recipe2) ingres.append(ingre) outputs.append(output) if shapeless: self.recipes.add_shapeless_recipe(recipe3, output) else: self.recipes.add_recipe(recipe, ingre, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i]) def test_add_4(self): self.test_add_1(characters='!@#$123456789') def test_add_5(self): self.test_add_2(characters='!@#$123456789')
class CraftingTests(unittest.TestCase): current_block_id = 0 def generate_random_recipe(self, characters='#@'): recipe = [] recipe2 = [] recipe3 = [] ingre = {} for character in characters: ingre[character] = list( G.BLOCKS_DIR.values())[self.current_block_id] self.current_block_id += 1 if self.current_block_id >= len(list(G.BLOCKS_DIR.values())): self.current_block_id = 0 for i in range(0, 3): recipe.append(''.join(random.choice(characters) for x in range(3))) recipe2.append([]) for character in recipe[i]: recipe2[i].append(ingre[character]) recipe3.append(ingre[character]) return recipe, ingre, ItemStack( random.choice(list(G.BLOCKS_DIR.values())).id, amount=random.randint(1, 20)), recipe2, recipe3 def test_add_1(self, characters='#@'): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in range(0, 50): recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( characters=characters) recipes.append(recipe2) ingres.append(ingre) outputs.append(output) self.recipes.add_recipe(recipe, ingre, output) self.assertEqual(self.recipes.nr_recipes, 50) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i]) def test_add_2(self, characters='#@'): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in range(0, 25): recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( characters=characters) recipes.append(recipe2) ingres.append(ingre) outputs.append(output) self.recipes.add_shapeless_recipe(recipe3, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i]) def test_add_3(self): self.recipes = Recipes() recipes = [] ingres = [] outputs = [] for i in range(0, 25): shapeless = random.choice([True, False]) if shapeless: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( ) else: recipe, ingre, output, recipe2, recipe3 = self.generate_random_recipe( characters='12') recipes.append(recipe2) ingres.append(ingre) outputs.append(output) if shapeless: self.recipes.add_shapeless_recipe(recipe3, output) else: self.recipes.add_recipe(recipe, ingre, output) for i, recipe in enumerate(recipes): self.assertEqual(self.recipes.craft(recipe), outputs[i]) def test_add_4(self): self.test_add_1(characters='!@#$123456789') def test_add_5(self): self.test_add_2(characters='!@#$123456789')