Rename the notion of parameters to arguments
What we called parameters are really in fact arguments. Let's name them as such. Change-Id: I1fe97ac6856f5a971a811a596eafc04a2d87fc55
This commit is contained in:
parent
515519660c
commit
128270dd08
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 2.1.1 on 2018-10-09 15:35
|
||||
# Generated by Django 2.1.1 on 2018-10-14 16:18
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
@ -92,7 +92,7 @@ class Migration(migrations.Migration):
|
|||
('name', models.CharField(max_length=255, null=True)),
|
||||
('ansible_version', models.CharField(max_length=255)),
|
||||
('completed', models.BooleanField(default=False)),
|
||||
('parameters', models.BinaryField(max_length=4294967295)),
|
||||
('arguments', models.BinaryField(max_length=4294967295)),
|
||||
('file', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='playbooks', to='api.File')),
|
||||
('files', models.ManyToManyField(to='api.File')),
|
||||
('labels', models.ManyToManyField(to='api.Label')),
|
||||
|
|
|
@ -112,7 +112,7 @@ class Playbook(Duration):
|
|||
name = models.CharField(max_length=255, null=True)
|
||||
ansible_version = models.CharField(max_length=255)
|
||||
completed = models.BooleanField(default=False)
|
||||
parameters = models.BinaryField(max_length=(2 ** 32) - 1)
|
||||
arguments = models.BinaryField(max_length=(2 ** 32) - 1)
|
||||
file = models.ForeignKey(File, on_delete=models.CASCADE, related_name="playbooks")
|
||||
files = models.ManyToManyField(File)
|
||||
labels = models.ManyToManyField(Label)
|
||||
|
|
|
@ -157,7 +157,7 @@ class PlaybookSerializer(DurationSerializer):
|
|||
model = models.Playbook
|
||||
fields = "__all__"
|
||||
|
||||
parameters = CompressedObjectField(default=zlib.compress(json.dumps({}).encode("utf8")))
|
||||
arguments = CompressedObjectField(default=zlib.compress(json.dumps({}).encode("utf8")))
|
||||
file = FileSerializer()
|
||||
files = FileSerializer(many=True, default=[])
|
||||
hosts = HostSerializer(many=True, default=[])
|
||||
|
|
|
@ -23,7 +23,7 @@ from ara.api.tests import utils
|
|||
# constants for things like compressed byte strings or objects
|
||||
FILE_CONTENTS = "---\n# Example file"
|
||||
HOST_FACTS = {"ansible_fqdn": "hostname", "ansible_distribution": "CentOS"}
|
||||
PLAYBOOK_PARAMETERS = {"ansible_version": "2.5.5", "inventory": "/etc/ansible/hosts"}
|
||||
PLAYBOOK_ARGUMENTS = {"ansible_version": "2.5.5", "inventory": "/etc/ansible/hosts"}
|
||||
RESULT_CONTENTS = {"results": [{"msg": "something happened"}]}
|
||||
LABEL_DESCRIPTION = "label description"
|
||||
TASK_TAGS = ["always", "never"]
|
||||
|
@ -60,7 +60,7 @@ class PlaybookFactory(factory.DjangoModelFactory):
|
|||
|
||||
ansible_version = "2.4.0"
|
||||
completed = True
|
||||
parameters = utils.compressed_obj(PLAYBOOK_PARAMETERS)
|
||||
arguments = utils.compressed_obj(PLAYBOOK_ARGUMENTS)
|
||||
file = factory.SubFactory(FileFactory)
|
||||
|
||||
|
||||
|
|
|
@ -43,23 +43,23 @@ class PlaybookTestCase(APITestCase):
|
|||
self.assertEqual(playbook.name, "serializer-playbook")
|
||||
self.assertEqual(playbook.ansible_version, "2.4.0")
|
||||
|
||||
def test_playbook_serializer_compress_parameters(self):
|
||||
def test_playbook_serializer_compress_arguments(self):
|
||||
serializer = serializers.PlaybookSerializer(
|
||||
data={
|
||||
"ansible_version": "2.4.0",
|
||||
"file": {"path": "/path/playbook.yml", "content": factories.FILE_CONTENTS},
|
||||
"parameters": factories.PLAYBOOK_PARAMETERS,
|
||||
"arguments": factories.PLAYBOOK_ARGUMENTS,
|
||||
}
|
||||
)
|
||||
serializer.is_valid()
|
||||
playbook = serializer.save()
|
||||
playbook.refresh_from_db()
|
||||
self.assertEqual(playbook.parameters, utils.compressed_obj(factories.PLAYBOOK_PARAMETERS))
|
||||
self.assertEqual(playbook.arguments, utils.compressed_obj(factories.PLAYBOOK_ARGUMENTS))
|
||||
|
||||
def test_playbook_serializer_decompress_parameters(self):
|
||||
playbook = factories.PlaybookFactory(parameters=utils.compressed_obj(factories.PLAYBOOK_PARAMETERS))
|
||||
def test_playbook_serializer_decompress_arguments(self):
|
||||
playbook = factories.PlaybookFactory(arguments=utils.compressed_obj(factories.PLAYBOOK_ARGUMENTS))
|
||||
serializer = serializers.PlaybookSerializer(instance=playbook)
|
||||
self.assertEqual(serializer.data["parameters"], factories.PLAYBOOK_PARAMETERS)
|
||||
self.assertEqual(serializer.data["arguments"], factories.PLAYBOOK_ARGUMENTS)
|
||||
|
||||
def test_get_no_playbooks(self):
|
||||
request = self.client.get("/api/v1/playbooks")
|
||||
|
|
Loading…
Reference in New Issue