Merge "Add missing relationship from result to play" into feature/1.0
This commit is contained in:
commit
c6baa2249f
@ -1,4 +1,4 @@
|
||||
# Generated by Django 2.1.5 on 2019-01-10 22:42
|
||||
# Generated by Django 2.1.7 on 2019-02-22 19:43
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
@ -126,6 +126,7 @@ class Migration(migrations.Migration):
|
||||
('status', models.CharField(choices=[('ok', 'ok'), ('failed', 'failed'), ('skipped', 'skipped'), ('unreachable', 'unreachable'), ('changed', 'changed'), ('ignored', 'ignored'), ('unknown', 'unknown')], default='unknown', max_length=25)),
|
||||
('content', models.BinaryField(max_length=4294967295)),
|
||||
('host', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='api.Host')),
|
||||
('play', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='api.Play')),
|
||||
('playbook', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='api.Playbook')),
|
||||
],
|
||||
options={
|
||||
|
@ -284,6 +284,7 @@ class Result(Duration):
|
||||
content = models.BinaryField(max_length=(2 ** 32) - 1)
|
||||
host = models.ForeignKey(Host, on_delete=models.CASCADE, related_name="results")
|
||||
task = models.ForeignKey(Task, on_delete=models.CASCADE, related_name="results")
|
||||
play = models.ForeignKey(Play, on_delete=models.CASCADE, related_name="results")
|
||||
playbook = models.ForeignKey(Playbook, on_delete=models.CASCADE, related_name="results")
|
||||
|
||||
def __str__(self):
|
||||
|
@ -109,6 +109,7 @@ class ResultFactory(factory.DjangoModelFactory):
|
||||
status = "ok"
|
||||
host = factory.SubFactory(HostFactory)
|
||||
task = factory.SubFactory(TaskFactory)
|
||||
play = factory.SubFactory(PlayFactory)
|
||||
playbook = factory.SubFactory(PlaybookFactory)
|
||||
|
||||
|
||||
|
@ -30,7 +30,13 @@ class ResultTestCase(APITestCase):
|
||||
host = factories.HostFactory()
|
||||
task = factories.TaskFactory()
|
||||
serializer = serializers.ResultSerializer(
|
||||
data={"status": "skipped", "host": host.id, "task": task.id, "playbook": task.playbook.id}
|
||||
data={
|
||||
"status": "skipped",
|
||||
"host": host.id,
|
||||
"task": task.id,
|
||||
"play": task.play.id,
|
||||
"playbook": task.playbook.id,
|
||||
}
|
||||
)
|
||||
serializer.is_valid()
|
||||
result = serializer.save()
|
||||
@ -43,7 +49,14 @@ class ResultTestCase(APITestCase):
|
||||
host = factories.HostFactory()
|
||||
task = factories.TaskFactory()
|
||||
serializer = serializers.ResultSerializer(
|
||||
data={"host": host.id, "task": task.id, "content": factories.RESULT_CONTENTS, "playbook": task.playbook.id}
|
||||
data={
|
||||
"content": factories.RESULT_CONTENTS,
|
||||
"status": "changed",
|
||||
"host": host.id,
|
||||
"task": task.id,
|
||||
"play": task.play.id,
|
||||
"playbook": task.playbook.id,
|
||||
}
|
||||
)
|
||||
serializer.is_valid()
|
||||
result = serializer.save()
|
||||
@ -79,10 +92,11 @@ class ResultTestCase(APITestCase):
|
||||
request = self.client.post(
|
||||
"/api/v1/results",
|
||||
{
|
||||
"content": factories.RESULT_CONTENTS,
|
||||
"status": "ok",
|
||||
"host": host.id,
|
||||
"task": task.id,
|
||||
"content": factories.RESULT_CONTENTS,
|
||||
"play": task.play.id,
|
||||
"playbook": task.playbook.id,
|
||||
},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user