Renommage des consoles en plateformes
parent
0380bc9071
commit
b0978034b5
@ -1,44 +1,44 @@
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 1
|
||||
fields:
|
||||
name: Steam
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 2
|
||||
fields:
|
||||
name: Game Boy
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 3
|
||||
fields:
|
||||
name: Nintendo 3DS
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 4
|
||||
fields:
|
||||
name: Nintendo Switch
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 5
|
||||
fields:
|
||||
name: PC
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 6
|
||||
fields:
|
||||
name: Genesis / Mega Drive
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 7
|
||||
fields:
|
||||
name: Nintendo Entertainment System
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 8
|
||||
fields:
|
||||
name: PlayStation
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 9
|
||||
fields:
|
||||
name: PlayStation 3
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 10
|
||||
fields:
|
||||
name: PlayStation 4
|
||||
- model: games.console
|
||||
- model: games.platform
|
||||
pk: 11
|
||||
fields:
|
||||
name: Wii
|
||||
|
@ -0,0 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.5 on 2017-09-16 15:05
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('games', '0007_help_text_on_console_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Console',
|
||||
new_name='Platform',
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='game',
|
||||
name='collection',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='games', to='games.Platform', verbose_name='platform'),
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='Platform',
|
||||
options={
|
||||
'verbose_name': 'platform',
|
||||
'verbose_name_plural': 'platforms',
|
||||
'ordering': ('name',),
|
||||
},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='platform',
|
||||
name='name',
|
||||
field=models.CharField(help_text='Most used platform name.', max_length=255, verbose_name='nom'),
|
||||
),
|
||||
]
|
@ -1,8 +1,8 @@
|
||||
from games.models import Console
|
||||
from games.models import Platform
|
||||
from rest_framework import serializers
|
||||
|
||||
|
||||
class ConsoleSerializer(serializers.ModelSerializer):
|
||||
class PlatformSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Console
|
||||
model = Platform
|
||||
fields = ('name',)
|
||||
|
@ -1,20 +1,20 @@
|
||||
from django.test import TestCase
|
||||
from games.models import Console
|
||||
from games.models import Platform
|
||||
|
||||
|
||||
class ConsoleTest(TestCase):
|
||||
class PlatformTest(TestCase):
|
||||
"""
|
||||
Console Model
|
||||
Platform Model
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
Console.objects.create(name='GP2X')
|
||||
Console.objects.create(name='3DS')
|
||||
Platform.objects.create(name='GP2X')
|
||||
Platform.objects.create(name='3DS')
|
||||
|
||||
|
||||
def test_console_are_sorted_by_name(self):
|
||||
consoles = list(Console.objects.all().values_list('name', flat=True))
|
||||
sorted_consoles = list(
|
||||
Console.objects.all().order_by('name').values_list(
|
||||
def test_platform_are_sorted_by_name(self):
|
||||
platforms = list(Platform.objects.all().values_list('name', flat=True))
|
||||
sorted_platforms = list(
|
||||
Platform.objects.all().order_by('name').values_list(
|
||||
'name', flat=True))
|
||||
self.assertEqual(consoles, sorted_consoles)
|
||||
self.assertEqual(platforms, sorted_platforms)
|
||||
|
Loading…
Reference in New Issue