Skip to content

Commit

Permalink
[Fixes #10192] Include source into the ExecutionRequest model (#10193) (
Browse files Browse the repository at this point in the history
#10207)

Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>

Co-authored-by: mattiagiupponi <51856725+mattiagiupponi@users.noreply.github.com>
Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>
  • Loading branch information
3 people authored Oct 27, 2022
1 parent 1fcbaff commit 5dec78d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
24 changes: 24 additions & 0 deletions geonode/resource/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,27 @@ def test_endpoint_should_raise_error_if_pk_is_not_passed(self):

self.assertEqual(500, response.status_code)
self.assertDictEqual(expected, response.json())

def test_endpoint_should_return_the_source(self):
# creating dummy execution request
obj = ExecutionRequest.objects.create(
user=self.superuser,
func_name='import_new_resource',
action="import",
source="upload_workflow"
)
self.client.force_login(self.superuser)

_url = f"{reverse('executionrequest-list')}/{obj.exec_id}"

response = self.client.get(_url)
self.assertEqual(200, response.status_code)
self.assertIsNotNone(response.json())
payload = response.json()

source = payload.get("request", {}).get("source", None)
self.assertIsNotNone(source)
self.assertEqual('upload_workflow', source)

# cleanup
obj.delete()
18 changes: 18 additions & 0 deletions geonode/resource/migrations/0008_executionrequest_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.16 on 2022-10-25 07:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('resource', '0007_alter_executionrequest_action'),
]

operations = [
migrations.AddField(
model_name='executionrequest',
name='source',
field=models.CharField(default=None, max_length=250, null=True),
),
]
2 changes: 2 additions & 0 deletions geonode/resource/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ class ExecutionRequest(models.Model):
default=ExecutionRequestAction.UNKNOWN.value,
null=True
)

source = models.CharField(max_length=250, null=True, default=None)

0 comments on commit 5dec78d

Please sign in to comment.