Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
 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]]))
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
def game():
    return GameFactory()
Ejemplo n.º 8
0
 def information_serial(self):
     return {
         'description': 'a' * 51,
         'launch_year': 1980,
         'game_id': GameFactory().pk
     }
Ejemplo n.º 9
0
def list_games(num_games=2):
    return GameFactory.create_batch(num_games)
Ejemplo n.º 10
0
 def image_str(self):
     image = GameFactory.build(name=None,
                               official_repository=None).cover_image.file
     return base64.b64encode(image.read()).decode('utf-8')
Ejemplo n.º 11
0
def game():
    GameFactory(game_activated=False)
    return GameFactory()
Ejemplo n.º 12
0
 def game(self):
     return GameFactory()
Ejemplo n.º 13
0
def game_created():
    game = GameFactory(name="game")
    return game
Ejemplo n.º 14
0
 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"
Ejemplo n.º 15
0
 def test_architecture_validation(self, architecture, errors_dict,
                                  platform):
     package = PackageFactory.build(architecture=architecture,
                                    game=GameFactory())
     validation_test(package, errors_dict)
Ejemplo n.º 16
0
 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