Skip to content
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

make sure comment and poll can only be added with egreement and… #1130

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

@github-actions
Copy link

github-actions bot commented Jun 27, 2022

Coverage report

Total coverage

Status Category Percentage Covered / Total
🔴 Statements 9.38% 103/1098
🔴 Branches 9.55% 68/712
🔴 Functions 10.39% 37/356
🔴 Lines 15.66% 529/3379

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Report generated by 🧪jest coverage report action from 3838ba8

@fuzzylogic2000 fuzzylogic2000 force-pushed the kl-2022-06-checkbox-tests branch 5 times, most recently from 1fb8103 to ca15c1c Compare July 4, 2022 13:09
@fuzzylogic2000 fuzzylogic2000 force-pushed the kl-2022-06-checkbox-tests branch 2 times, most recently from ece164c to 2c7b968 Compare July 5, 2022 09:05
@fuzzylogic2000 fuzzylogic2000 changed the title WIP: make sure comment and poll can only be added with egreement and… make sure comment and poll can only be added with egreement and… Jul 5, 2022
@@ -93,6 +113,10 @@ def vote(self, request, pk):
self.request.data['agreed_terms_of_use']
}
)
else:
raise ValidationError({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the poll, it does not matter which error, I use, it always gives "Your answer could not be saved. Please check the data you entered again.". I will add an issue for that, but would not like to handle that in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that comes from frontend, we catch errors there, but then always show 'Your answer...'. So we should probably show the actual message of error there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's comment in here: #1141

@fuzzylogic2000 fuzzylogic2000 force-pushed the kl-2022-06-checkbox-tests branch 3 times, most recently from c5172aa to a11fb9b Compare July 5, 2022 10:01
@goapunk
Copy link
Contributor

goapunk commented Jul 5, 2022

@fuzzylogic2000 but the tests are working now?

@fuzzylogic2000
Copy link
Contributor Author

@fuzzylogic2000 but the tests are working now?

@goapunk Yes! I had to patch the reverse that is imported into the api. Which does make sense, but took me a while...

if hasattr(request, 'user'):
user = request.user
if user.is_authenticated:
user_has_agreed = \
user.has_agreed_on_org_terms(organisation)
user_has_agreed = self._user_has_agreed(user)
Copy link
Contributor

Choose a reason for hiding this comment

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

see comment in comments

if hasattr(request, 'user'):
user = request.user
if user.is_authenticated:
user_has_agreed = \
user.has_agreed_on_org_terms(organisation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could still use user.has_agreed_on_org_terms here? Because we already have the organisation object here and then dont have to get it again in self._user_has_agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weeeeeell, I changed it because otherwise the tests do not work. Which is a weird reason, but I just could not find anything faking a property. And I would still like to test in a4, so we cannot really use the property that we only have in a+. So, don't know. 😢

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, I see! But doing all these queries to make the test work also doesnt seem right, no? Maybe we can just move the failing tests to Aplus? Or is it all of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, for the poll it would be all of them. And I think, if we use user.has_agreed_on_org_terms in the API, we should also check that it is implemented and otherwise throw an error. Just relying on that it's there in the project also does not seem like the best way to go.

Copy link
Contributor

@Rineee Rineee left a comment

Choose a reason for hiding this comment

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

Supercool! Better structured and so many tests!

I just have one tiny suggestion..

@fuzzylogic2000 fuzzylogic2000 force-pushed the kl-2022-06-checkbox-tests branch from a11fb9b to 3838ba8 Compare July 5, 2022 16:04
@fuzzylogic2000 fuzzylogic2000 requested a review from Rineee July 5, 2022 16:05
@fuzzylogic2000
Copy link
Contributor Author

@Rineee I changed the names of the tests and added a few doctsrings. I hope it is a bit more structured and easy to see what I actually test now. :)

@Rineee Rineee merged commit 9382cbf into main Jul 6, 2022
@Rineee Rineee deleted the kl-2022-06-checkbox-tests branch July 6, 2022 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants