Skip to content

Conversation

@stktyagi
Copy link
Member

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #1040.

Description of Changes

Added ordering by creation date (descending) to the Base command view to ensure consistent and expected command ordering and checked all other list apis to ensure recency.
Tests to supported the same added.

@stktyagi
Copy link
Member Author

@nemesifier
I've created a new pull request which follows the contributing guidelines.

@stktyagi stktyagi force-pushed the issue/1040-added-recency-tests branch 3 times, most recently from 72c4e9e to d079110 Compare May 17, 2025 19:23
@stktyagi
Copy link
Member Author

updated commit message to prevent build failure.

@nemesifier nemesifier changed the title Issue/1040 added recency tests [fix] Ensure recent items are shown first in the REST API May 23, 2025
@nemesifier nemesifier added the bug label May 23, 2025
@coveralls
Copy link

coveralls commented May 23, 2025

Coverage Status

coverage: 98.816%. remained the same
when pulling 2559be8 on stktyagi:issue/1040-added-recency-tests
into 85eee35 on openwisp:master.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stktyagi it looks good to me! I just want to find some time to double check this is the only endpoint where we need to fix this.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other endpoints I found that are suffering from the same issue:

  • /api/v1/controller/group/
  • /api/v1/controller/device/

Can we take advantage and fix those as well?

Regarding the tests, I recommend extending the existing tests for these endpoints with a subtest which checks the ordering, let's try to reduce the new lines to the bare minimuim required to test the ordering effectively.

Please also update your local copy of openwisp-utils to the latest master, reinstall it to update the dependencies and run openwisp-qa-format again as there's been slight changes to the QA dependencies and configuration (see openwisp/openwisp-utils#473 and openwisp/openwisp-utils#456).

See also my comments below.

stktyagi and others added 6 commits June 6, 2025 12:46
Fixed bug where device connections were not properly filtered in the API response with recency with new tests added.
Fixes openwisp#1040
Fixed bug where device connections were not properly filtered in the API response with recency with new tests added. All the command list endpoint models were updated.

Fixes openwisp#1040
Added and tested recency tests for config /group and /device endpoints. Updated tests(added as subtests) for previously fixed and recently fixed endpoints.

Fixes openwisp#1040
@stktyagi stktyagi force-pushed the issue/1040-added-recency-tests branch from f915d33 to 40f7b91 Compare June 6, 2025 07:21
@stktyagi
Copy link
Member Author

stktyagi commented Jun 6, 2025

@nemesifier greetings,
updated test files with new subtests instead of redundant test functions and updated logic to avoid bloat.
Tested for all endpoints which include 2 of the previous ones, /group and /device.
complied with new qa-tests.

@stktyagi stktyagi requested a review from nemesifier June 8, 2025 07:51
@pandafy pandafy moved this from To do (general) to In progress in OpenWISP Contributor's Board Jun 10, 2025
Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must have made some confusion during the previous review because I see that device and device group are already ordered properly. Well, that's good to know, thanks for adding the tests! I did some minor simplifications, should be ready to merge.

r = self.client.get(path)
self.assertEqual(r.status_code, 200)
with self.subTest("should return devices ordered by most recent first"):
Device.objects.all().delete()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? We could avoid it and add only 2 more devices so we end up with 3.

@github-project-automation github-project-automation bot moved this from In progress to Reviewer approved in OpenWISP Priorities for next releases Jun 12, 2025
@nemesifier nemesifier merged commit d449e9b into openwisp:master Jun 12, 2025
13 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in OpenWISP Contributor's Board Jun 12, 2025
@github-project-automation github-project-automation bot moved this from Reviewer approved to Done in OpenWISP Priorities for next releases Jun 12, 2025
@stktyagi stktyagi deleted the issue/1040-added-recency-tests branch June 13, 2025 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

[bug] REST API showing most recent as last

3 participants