Merge "Add an uuid field for the play model and API"
This commit is contained in:
commit
1d3860a705
|
@ -1,8 +1,8 @@
|
|||
# Generated by Django 2.1.1 on 2018-09-07 17:53
|
||||
# Generated by Django 2.1.1 on 2018-10-09 15:35
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@ -74,6 +74,7 @@ class Migration(migrations.Migration):
|
|||
('started', models.DateTimeField(default=django.utils.timezone.now)),
|
||||
('ended', models.DateTimeField(blank=True, null=True)),
|
||||
('name', models.CharField(blank=True, max_length=255, null=True)),
|
||||
('uuid', models.UUIDField()),
|
||||
('completed', models.BooleanField(default=False)),
|
||||
],
|
||||
options={
|
||||
|
|
|
@ -150,6 +150,7 @@ class Play(Duration):
|
|||
db_table = "plays"
|
||||
|
||||
name = models.CharField(max_length=255, blank=True, null=True)
|
||||
uuid = models.UUIDField()
|
||||
completed = models.BooleanField(default=False)
|
||||
playbook = models.ForeignKey(Playbook, on_delete=models.CASCADE, related_name="plays")
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ class PlayFactory(factory.DjangoModelFactory):
|
|||
|
||||
name = "test play"
|
||||
completed = True
|
||||
uuid = "5c5f67b9-e63c-6297-80da-000000000005"
|
||||
playbook = factory.SubFactory(PlaybookFactory)
|
||||
|
||||
|
||||
|
|
|
@ -31,7 +31,14 @@ class PlayTestCase(APITestCase):
|
|||
|
||||
def test_play_serializer(self):
|
||||
playbook = factories.PlaybookFactory()
|
||||
serializer = serializers.PlaySerializer(data={"name": "serializer", "completed": True, "playbook": playbook.id})
|
||||
serializer = serializers.PlaySerializer(
|
||||
data={
|
||||
"name": "serializer",
|
||||
"completed": True,
|
||||
"uuid": "5c5f67b9-e63c-6297-80da-000000000005",
|
||||
"playbook": playbook.id,
|
||||
}
|
||||
)
|
||||
serializer.is_valid()
|
||||
play = serializer.save()
|
||||
play.refresh_from_db()
|
||||
|
@ -57,7 +64,15 @@ class PlayTestCase(APITestCase):
|
|||
def test_create_play(self):
|
||||
playbook = factories.PlaybookFactory()
|
||||
self.assertEqual(0, models.Play.objects.count())
|
||||
request = self.client.post("/api/v1/plays", {"name": "create", "completed": False, "playbook": playbook.id})
|
||||
request = self.client.post(
|
||||
"/api/v1/plays",
|
||||
{
|
||||
"name": "create",
|
||||
"completed": False,
|
||||
"uuid": "5c5f67b9-e63c-6297-80da-000000000005",
|
||||
"playbook": playbook.id,
|
||||
},
|
||||
)
|
||||
self.assertEqual(201, request.status_code)
|
||||
self.assertEqual(1, models.Play.objects.count())
|
||||
|
||||
|
|
Loading…
Reference in New Issue