def create_game(self, name, nchains=1, depth=0, num_seeds_per_chain=1): """Create a game with the specified number of chains. Args: name: The name of the game to create. nchains: The number of chains to add to the game. Names for the chains are created automatically. depth: The number of recordings to add to each chain. num_seeds_per_chain: The number of seeds to add to each chain. """ game = Game(name=name) game.full_clean() game.save() for n in range(nchains): chain = Chain(game=game, name='chain {}'.format(n)) chain.full_clean() chain.save() for seed_ix in range(num_seeds_per_chain): seed_file = File(open(self.path_to_test_audio(), 'rb')) seed_message = Message(chain=chain, audio=seed_file) seed_message.full_clean() seed_message.save() seed_file.close() def add_child(chain): parent = chain.pick_parent() with open(self.path_to_test_audio(), 'rb') as test_audio_handle: test_audio = File(test_audio_handle) child = Message(chain=chain, parent=parent, audio=test_audio) child.full_clean() child.save() parent.kill() for chain in game.chains.all(): for _ in range(depth): add_child(chain)
def test_make_a_chain(self): """ Make a chain """ chain = Chain(game=self.game, name='New Chain') chain.full_clean() chain.save()