def test_game_list_content(self, client): GameFactory.create_batch(3) GameFactory(game_activated=False) gameList = Game.objects.exclude(game_activated=False) response = client.get('/api/games/') assert gameList.count() == len(response.data)
def test_valid_package_extensions(self, extension): PlatformFactory(extensions=extension) package = PackageFactory.build(game=GameFactory()) package.package.name = package.package.name.replace('deb', extension) package.save() assert package == Package.objects.last()
def test_package(self): PlatformFactory() package = PackageFactory.build(game=GameFactory()) with patch("game.validators._get_size", return_value=1 + 1024**3): validation_test( package, mount_error_dict(["package"], [[ErrorMessage.FILE_TOO_BIG]]))
def test_save_instances(self, form, attr, factory, mock): form.cleaned_data = {'game': GameFactory(), 'role': 'slider'} list_files = [getattr(factory, attr).file] with mock.patch("media.forms.MediaForm.update_medias", return_value=list_files): form.save_instances(list_files, factory, False, attr) assert factory.__class__.objects.count() == 1
def game(self): platform = Platform() video_game = Video() sound_game = Soundtrack() award_game = Award() developer = Developer() information_game = Information() game = GameFactory() ImageFactory(game=game) package_game = PackageFactory.build(game=game) platform.name = 'Ubuntu' platform.extensions = EXTENSION_CHOICES[0][0] platform.icon = 'Platform/linux.png' platform.save() package_game.save() package_game.platforms.add(platform) video_game.video = 'videos/exemplo.mp4' video_game.role = ROLE_CHOICES[0][0] video_game.game_id = game.id video_game.save() sound_game.soundtrack = 'soundtrack/exemplo.mp3' sound_game.role = ROLE_CHOICES[0][0] sound_game.game_id = game.id sound_game.save() award_game.name = 'Game of the year' award_game.year = 2014 award_game.place = 'Conference game' award_game.save() developer.name = 'Developer 1' developer.login = '******' developer.github_page = 'https://github.com/PlataformaJogosUnb/' developer.save() information_game.description = 'This is a test game used to test the\ serializer of the model game.' information_game.launch_year = 2013 information_game.semester = 1 information_game.game = game information_game.save() information_game.developers.add(developer) information_game.awards.add(award_game) return game
def game(self): credit = CreditFactory() award_game = AwardFactory() game = GameFactory() InformationFactory(game=game, awards=[award_game], credits=[credit]) ImageFactory(game=game) PlatformFactory() PackageFactory(game=game) VideoFactory(game=game) SoundtrackFactory(game=game) return game
def game(): return GameFactory()
def information_serial(self): return { 'description': 'a' * 51, 'launch_year': 1980, 'game_id': GameFactory().pk }
def list_games(num_games=2): return GameFactory.create_batch(num_games)
def image_str(self): image = GameFactory.build(name=None, official_repository=None).cover_image.file return base64.b64encode(image.read()).decode('utf-8')
def game(): GameFactory(game_activated=False) return GameFactory()
def game(self): return GameFactory()
def game_created(): game = GameFactory(name="game") return game
def test_str_game(self): game = GameFactory.build(version=None, name="Game") assert str(game) == "Game" game.version = "1.1" assert str(game) == "Game v1.1"
def test_architecture_validation(self, architecture, errors_dict, platform): package = PackageFactory.build(architecture=architecture, game=GameFactory()) validation_test(package, errors_dict)
def test_update_medias(self, form, media, attr): form.cleaned_data = {'game': GameFactory(), 'role': 'slider'} list_files = [getattr(media, attr).file] assert [] == form.update_medias(media, list_files, True, attr) assert media.__class__.objects.count() == 1