예제 #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
 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]]))
예제 #3
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()
예제 #4
0
 def __single_data__(self, *args, **kwargs):
     self.stdout.write("Start the creation of dummy data")
     genre = GenreFactory.create_batch(kwargs['non_loop'])
     self.stdout.write("Genre: {}".format("." * kwargs['non_loop']))
     award = AwardFactory.create_batch(kwargs['non_loop'])
     self.stdout.write("Award: {}".format("." * kwargs['non_loop']))
     PlatformFactory()
     self.stdout.write("Platform: .")
     return (genre, award)
예제 #5
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()
예제 #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
예제 #7
0
    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
예제 #8
0
def platforms_list():
    return PlatformFactory.create_batch(2)
예제 #9
0
def platform():
    return PlatformFactory()
예제 #10
0
 def test_str(self):
     platform = PlatformFactory.build()
     assert str(platform) == '{} (.deb)'.format(platform.name)
예제 #11
0
 def test_field_validation(self, field, value, errors_dict):
     platform = PlatformFactory.build()
     setattr(platform, field, value)
     validation_test(platform, errors_dict)