コード例 #1
0
    def test_update_relationships(self, platform):
        platform.extensions = 'deb'
        package = PackageFactory()
        package.package.file = 'package.deb'

        platform.save()
        package.save()
        assert package.platforms.last().pk == platform.pk

        platform2 = PlatformFactory(extensions='deb')
        platform2.save()
        assert package.platforms.last().pk == platform2.pk
        assert package.platforms.count() == 2
コード例 #2
0
ファイル: test_views.py プロジェクト: lappis-unb/UnBGames
 def test_package_downloads(self, client, game, platform):
     package = PackageFactory(game=game)
     respons = client.post("/api/packages/{}/downloads/".format(package.pk))
     assert 200 <= respons.status_code < 300
     assert respons.data == {'update': 'downloads count increase'}
     downloads = Package.objects.get(pk=package.pk).downloads
     assert downloads == package.downloads + 1
コード例 #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]]))
コード例 #4
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()
コード例 #5
0
ファイル: test_views.py プロジェクト: lappis-unb/UnBGames
 def test_game_platforms(self, client, game, platform):
     packages = PackageFactory.create_batch(1, game=game)
     response = client.get("/api/games/{}/platforms/".format(game.pk))
     packages = PackageSerializer(packages, many=True).data
     for pack in packages:
         pack['platforms'] = ' / '.join(
             [p.get('name') for p in pack['platforms']])
     assert response.data == {platform.kernel: packages}
コード例 #6
0
 def test_size_validation(self):
     error_message = "Please keep filesize under 1,0 GB. " \
                     "Current filesize 10 bytes"
     PlatformFactory()
     package_package = PackageFactory().package
     package = patch("game.validators._get_size", return_value=1 + 1024**3)
     package.start()
     with pytest.raises(ValidationError) as validation_error:
         validate_package_size(package_package)
     assert validation_error.value.message == error_message
     package.stop()
コード例 #7
0
ファイル: test_views.py プロジェクト: lappis-unb/UnBGames
    def test_package_save(self, admin_client, game, platform):
        pack = PackageFactory.build().package
        response = admin_client.post('/api/packages/', {
            'package': pack.file,
            'game_id': game.pk,
            'architecture': 'X86/32-bit'
        },
                                     format='multipart')

        assert 200 <= response.status_code < 300
        assert Package.objects.count() == 1
        package = Package.objects.last()
        assert package.game.pk == game.pk
コード例 #8
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
コード例 #9
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
コード例 #10
0
    def __multiple_data__(self, genre, award, *args, **kwargs):
        for i in range(1, kwargs['loop'] + 1):
            self.stdout.write("Game {}:".format(i))
            developer = DeveloperFactory.create_batch(kwargs['non_loop'])
            self.stdout.write("\tDeveloper: {}".format("." *
                                                       kwargs['non_loop']))

            information = InformationFactory.create(
                awards=[award[i % kwargs['non_loop']]],
                developers=developer,
                genres=[genre[i % kwargs['non_loop']]])
            self.stdout.write("\tInformation: .")
            ImageFactory.create_batch(kwargs['media'], game=information.game)
            self.stdout.write("\tImage: {}".format("." * kwargs['media']))
            VideoFactory.create_batch(kwargs['video'], game=information.game)
            self.stdout.write("\tVideo: {}".format("." * kwargs['video']))
            PackageFactory(game=information.game)
            self.stdout.write("\tPackage: .")
コード例 #11
0
ファイル: test_views.py プロジェクト: lappis-unb/UnBGames
    def __games__(self, genres, field, factor):
        PlatformFactory()
        info1 = self.__information__([genres[0], genres[1]])
        info2 = self.__information__([genres[2], genres[3]])
        info3 = self.__information__([genres[1], genres[2], genres[3]])
        info4 = self.__information__(genres)
        games = {
            genres[0].name: [info1, info4],
            genres[1].name: [info1, info3, info4],
            genres[2].name: [info2, info3, info4],
            genres[3].name: [info2, info3, info4],
        }
        for info in [info1, info2, info3, info4]:
            PackageFactory(game=info)

        f = -1 if factor == '-' else 1
        for key in games:
            games[key].sort(key=lambda x: f * getattr(x, field))
            games[key] = GameSerializer(games[key], many=True)
            games[key] = games[key].data
        return games
コード例 #12
0
ファイル: test_views.py プロジェクト: lappis-unb/UnBGames
def batch_games_packages(platform):
    return [pack.game for pack in PackageFactory.create_batch(6)]
コード例 #13
0
 def package(self):
     return PackageFactory()
コード例 #14
0
 def test_package_str(self, platform):
     package = PackageFactory()
     assert str(package) == "{} (.deb)".format(package.game.name)
コード例 #15
0
ファイル: test_models.py プロジェクト: lappis-unb/UnBGames
 def test_architecture_validation(self, architecture, errors_dict,
                                  platform):
     package = PackageFactory.build(architecture=architecture,
                                    game=GameFactory())
     validation_test(package, errors_dict)