-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Database split part II: KobocatDeploymentBackend refactoring #2186
Conversation
…entBackend' and 'SubmissionViewSet'. Unittests
… asset (before triggerring the hook)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfinished review; submitting so @noliveleger can see my comments
prepared_drf_response["data"] = json.loads(requests_response.content) | ||
except ValueError as e: | ||
if not requests_response.status_code == status.HTTP_204_NO_CONTENT: | ||
raise Exception(str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Would it be better to re-raise a
ValueError
instead of a genericException
? - Maybe
str(e)
should be prefixed with "KoBoCAT returned an unexpected response: " or similar (to avoid the unhelpfulNo JSON object could be decoded
message that people get in the current release)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the code a little bit.
The error is returned in the response. FE
can expose the message to users.
For example, if submission deletion fails, nothing happens. It would be better to display a message to users. (cc @magicznyleszek)
kpi/tests/test_api_submissions.py
Outdated
|
||
class SubmissionApiTests(BaseTestCase): | ||
|
||
def test_create_submission(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say test_cannot_create_submission
kpi/tests/test_api_submissions.py
Outdated
|
||
def test_delete_submission_shared_other_write(self): | ||
self._other_user_login(True) | ||
self.asset.assign_perm(self.anotheruser, "change_submissions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment moved to #2282
kpi/tests/test_api_submissions.py
Outdated
"pk": self.submission.get("id") | ||
}) | ||
|
||
def test_trigger_signal(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which signal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad test name. Nothing related to signal. I have renamed it.
I also noticed that few others tests were missing (e.g. get edit link for viewers only), so I added them.
353d6da
to
f728b9c
Compare
… KobocatBackend.get_submissions()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have a call and go through this together
Based on #2155.
Fixes #2036
Because some parts of the code in
KobocatDeploymentBackend
andKobocatDataProxyViewSetMixin
were doing the same thing,KobocatDeploymentBackend
has been refactoring to regroup all the logic forkc
proxy.Even
SubmissionViewSet
has been refactored to use new methods ofKobocatDeploymentBackend
and to benefit PROs of DRF (permissions, renderers)A new viewset has been created to handle hook signals from
kobocat
(Don't merge until kobotoolbox/kobocat#523 is reviewed and merged too)