Skip to content

Commit

Permalink
Fix upload serialization argument vs env_vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Tansito committed Mar 13, 2024
1 parent 490a6ab commit e2a6e82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions gateway/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Meta(serializers.ProgramSerializer.Meta):
"entrypoint",
"artifact",
"dependencies",
"env_vars",
"arguments",
"public",
]

Expand All @@ -38,8 +38,7 @@ class Meta(serializers.UploadProgramSerializer.Meta):
"entrypoint",
"artifact",
"dependencies",
"env_vars",
"public",
"arguments",
]


Expand Down
14 changes: 6 additions & 8 deletions gateway/tests/api/test_v1_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def test_upload_program_serializer_creates_program(self):

title = "Hello world"
entrypoint = "pattern.py"
env_vars = "{}"
arguments = "{}"
dependencies = "[]"

data = {}
data["title"] = title
data["entrypoint"] = entrypoint
data["env_vars"] = env_vars
data["arguments"] = arguments
data["dependencies"] = dependencies
data["artifact"] = upload_file

Expand All @@ -71,7 +71,7 @@ def test_upload_program_serializer_creates_program(self):
program: Program = serializer.save(author=user)
self.assertEqual(title, program.title)
self.assertEqual(entrypoint, program.entrypoint)
self.assertEqual(env_vars, program.env_vars)
self.assertEqual(arguments, program.arguments)
self.assertEqual(dependencies, program.dependencies)

def test_upload_program_serializer_fails_at_validation(self):
Expand All @@ -86,8 +86,6 @@ def test_upload_program_serializer_fails_at_validation(self):
"artifact.tar", data.read(), content_type="multipart/form-data"
)

user = models.User.objects.get(username="test_user")

title = "Hello world"
entrypoint = "pattern.py"

Expand All @@ -98,15 +96,15 @@ def test_upload_program_serializer_fails_at_validation(self):
errors = serializer.errors
self.assertListEqual(["title", "entrypoint", "artifact"], list(errors.keys()))

env_vars = {}
arguments = {}
dependencies = []
data["title"] = title
data["entrypoint"] = entrypoint
data["artifact"] = upload_file
data["env_vars"] = env_vars
data["arguments"] = arguments
data["dependencies"] = dependencies

serializer = UploadProgramSerializer(data=data)
self.assertFalse(serializer.is_valid())
errors = serializer.errors
self.assertListEqual(["dependencies", "env_vars"], list(errors.keys()))
self.assertListEqual(["dependencies", "arguments"], list(errors.keys()))

0 comments on commit e2a6e82

Please sign in to comment.