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
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_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 __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)
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()
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 __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
def platforms_list(): return PlatformFactory.create_batch(2)
def platform(): return PlatformFactory()
def test_str(self): platform = PlatformFactory.build() assert str(platform) == '{} (.deb)'.format(platform.name)
def test_field_validation(self, field, value, errors_dict): platform = PlatformFactory.build() setattr(platform, field, value) validation_test(platform, errors_dict)