Closed alukach closed 7 years ago
Looking at the Travis build, I see that the tests run against demo.cadasta.org
. These tests will fail until cadasta/cadasta-platform#1425 is merged to production. We may have to either bend that rule and run tests locally against a dev server or wait until the PR is merged to staging and run against that server.
Tests should never be run against demo. If tests need a live server, it should be staging. I'd favor a solution that uses some local instance though.
@oliverroick agreed, but not sure how that impacts this PR. Doing a search we can see that tests are run against demo.cadasta.org
in a few spots. It feels like our options are to:
platform-staging.cadasta.org
. We may also want to consider baking the credentials into environment variables (I'm assuming Travis supports this) rather than leaving it in the code.I'm leaning towards mocking out the network calls. This would make these more of a standard unit test rather than integration tests. It's the least amount of work, would allow us to get rid of storing credentials in the repo, could ensure that automated tests work for my branch. We lose the confidence of knowing that the API works in the way that the plugin's codebase expects.
Thoughts? Additionally, should this be done in this PR or another?
A PR has been made on the Cadasta Platform codebase to add pagination to all "list" API endpoints: Cadasta/cadasta-platform#1425. Naturally, that change will break the QGIS plugin.
This PR adds the ability for the QGIS plugin to follow pagination links. It works by altering the
NetworkMixin
to have a newconnect_get_paginated()
method. The flow is as follows:next
property, which will be a URL to the next page of dataNetworkMixin
instance and calls theconnect_get_paginated()
method on that instance, passing along the calling instance's API response as a payload and its_set_results_and_complete()
method as a callback.next
property, the API response handler calls the_set_results_and_complete()
callback with the final combined response object._set_results_and_complete()
of the original instance sets the response data to theNetworkMixin
that first calledconnect_get_paginated()
and sets its internalpagination_exhausted
flag toTrue
.Most of the codebase looks at
reply.isFinished()
to determine if a API request is complete. Being that the pattern of usingreply.isFinished()
to signal when the request is complete does not really apply to paginated data, a newis_finished(paginated=False)
method was added to theNetworkMixin
, returningself.reply.isFinished()
if the request is a normal request andself.pagination_exhausted
flag if the request is a paginated request.Additionally, along the way I noticed that many classes unnecessarily overrode their parent class'
__init__
orconnection_finished
classes. I went ahead and removed these methods. Additionally, it seemed to make sense to makerequest_url
a required input to theNetworkMixin
class.I've tested these changes out functionally but did not run unit tests nor did I write any unit tests.
@meomancer @dimasciput This code change may be out of scope for this project. I'd appreciate any comments you can offer or instructions regarding how to run the unit-tests.