-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1178 from akvo/feature/1166-monitoring-list-for-m…
…anage-data-api Showing Monitoring Data-point in the Manage Data Page
- Loading branch information
Showing
16 changed files
with
481 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
backend/api/v1/v1_data/migrations/0030_alter_formdata_parent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 4.0.4 on 2024-02-19 02:31 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('v1_data', '0029_formdata_parent'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='formdata', | ||
name='parent', | ||
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='children', to='v1_data.formdata'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,8 @@ def test_list_form_data(self): | |
['current', 'total', 'total_page', 'data']) | ||
self.assertEqual(list(result['data'][0]), [ | ||
'id', 'uuid', 'name', 'form', 'administration', 'geo', | ||
'created_by', 'updated_by', 'created', 'updated', 'pending_data' | ||
'created_by', 'updated_by', 'created', 'updated', 'pending_data', | ||
'children_count' | ||
]) | ||
self.assertIsNotNone(result['data'][0]['uuid']) | ||
|
||
|
@@ -203,3 +204,42 @@ def test_datapoint_with_history_deletion(self): | |
self.assertEqual(answers, 0) | ||
hitory = AnswerHistory.objects.filter(data_id=data_id).count() | ||
self.assertEqual(hitory, 0) | ||
|
||
def test_monitoring_details_by_parent_id(self): | ||
call_command("administration_seeder", "--test") | ||
user_payload = {"email": "[email protected]", "password": "Test105*"} | ||
user_response = self.client.post('/api/v1/login', | ||
user_payload, | ||
content_type='application/json') | ||
token = user_response.json().get('token') | ||
call_command("form_seeder", "--test") | ||
call_command("demo_approval_flow") | ||
call_command("fake_data_seeder", "-r", 1, "-t", True) | ||
call_command( | ||
"fake_data_monitoring_seeder", | ||
"-r", 5, | ||
"-t", True, | ||
"-a", True | ||
) | ||
|
||
header = {'HTTP_AUTHORIZATION': f'Bearer {token}'} | ||
|
||
monitoring = FormData.objects.filter(parent__isnull=False).first() | ||
parent = monitoring.parent | ||
form_id = monitoring.form.id | ||
url = f"/api/v1/form-data/{form_id}?page=1&parent={parent.id}" | ||
data = self.client.get( | ||
url, | ||
follow=True, | ||
**header | ||
) | ||
result = data.json() | ||
self.assertEqual(data.status_code, 200) | ||
self.assertEqual( | ||
list(result), | ||
['current', 'total', 'total_page', 'data'] | ||
) | ||
# total equal to number of children + the data itself | ||
self.assertEqual(result['total'], parent.children.count() + 1) | ||
# make sure the last item is parent | ||
self.assertEqual(result['data'][-1]['name'], parent.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.