Exemplo n.º 1
0
    def test_serialization_game_object(self, game):
        serialized_game = GameSerializer(game).data

        assert serialized_game.get('name') == game.name

        assert serialized_game.get('cover_image') == game.cover_image.url

        assert serialized_game.get(
            'official_repository') == game.official_repository

        assert serialized_game.get('version') == game.version
Exemplo n.º 2
0
    def test_serialization_medias_object(self, game):
        serialized_game = GameSerializer(game).data
        image_serialized = serialized_game.get('media_image')[0]
        video_serialized = serialized_game.get('media_video')[0]
        sound_serialized = serialized_game.get('media_soundtrack')[0]

        assert image_serialized.get(
            'image') == game.media_image.first().image.url

        assert video_serialized.get(
            'video') == game.media_video.first().video.url

        assert sound_serialized.get(
            'soundtrack') == game.media_soundtrack.first().soundtrack.url
Exemplo n.º 3
0
    def test_serialization_information_object(self, game):
        serialized_game = GameSerializer(game).data
        information_serialized = serialized_game.get('information')
        credit_serialized = information_serialized.get('credits')[0]
        award_serialized = information_serialized.get('awards')[0]

        assert information_serialized.get(
            'description') == game.information.description

        assert information_serialized.get(
            'launch_year') == game.information.launch_year

        assert credit_serialized == {
            'github_page': game.information.credits.first().github_page,
            'behance_page': game.information.credits.first().behance_page,
            'soundCloud_page':
            game.information.credits.first().soundCloud_page,
            'personal_page': game.information.credits.first().personal_page,
            'email': game.information.credits.first().email,
            'name': game.information.credits.first().name,
            'specialty': game.information.credits.first().specialty,
        }

        assert award_serialized == {
            'name': game.information.awards.first().name,
            'place': game.information.awards.first().place,
        }
Exemplo n.º 4
0
    def test_serialization_information_object(self, game):
        serialized_game = GameSerializer(game).data
        information_serialized = serialized_game.get('information')
        developer_serialized = information_serialized.get('developers')[0]
        award_serialized = information_serialized.get('awards')[0]

        assert information_serialized.get(
            'description') == game.information.description

        assert information_serialized.get(
            'launch_year') == game.information.launch_year

        assert developer_serialized == {
            'login': game.information.developers.first().login,
            'github_page': game.information.developers.first().github_page,
            'email': None,
            'avatar': None,
            'name': game.information.developers.first().name
        }

        assert award_serialized == {
            'name': game.information.awards.first().name,
            'year': game.information.awards.first().year,
            'place': game.information.awards.first().place,
        }
Exemplo n.º 5
0
    def test_serialization_extra_object(self, game):
        serialized_game = GameSerializer(game).data
        package_serialized = serialized_game.get('packages')[0]
        platform_serialized = package_serialized.get('platforms')[0]

        assert package_serialized.get(
            'package') == game.packages.first().package.url

        assert platform_serialized.get(
            'name') == game.packages.first().platforms.first().name

        assert platform_serialized.get(
            'extensions') == game.packages.first().platforms.first().extensions