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

test: Add tests for notification helper functions #6863

Merged
merged 4 commits into from
May 6, 2020
Merged

test: Add tests for notification helper functions #6863

merged 4 commits into from
May 6, 2020

Conversation

me-diru
Copy link
Contributor

@me-diru me-diru commented Feb 20, 2020

Fixes #6828
Part of #5320

Short description of what this resolves:

Increases test coverage by adding tests for notification helpers functions

Changes proposed in this pull request:

  • Added tests for notification helpers functions

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

@auto-label auto-label bot added the testing label Feb 20, 2020
test_session = SessionFactory()
link = common.url_
event_name = common.string_
current_app.config['TESTING'] = False

Choose a reason for hiding this comment

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

Black would make changes.

send_notif_session_accept_reject,
send_notif_ticket_purchase_organizer,
)
from app.api.helpers.db import save_to_db

Choose a reason for hiding this comment

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

'app.api.helpers.db.save_to_db' imported but unused

@@ -0,0 +1,148 @@
import unittest
from app.models import db

Choose a reason for hiding this comment

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

'app.models.db' imported but unused

@codecov
Copy link

codecov bot commented Feb 20, 2020

Codecov Report

Merging #6863 into development will increase coverage by 0.55%.
The diff coverage is 98.61%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #6863      +/-   ##
===============================================
+ Coverage        66.38%   66.94%   +0.55%     
===============================================
  Files              313      314       +1     
  Lines            15360    15423      +63     
===============================================
+ Hits             10197    10325     +128     
+ Misses            5163     5098      -65     
Impacted Files Coverage Δ
app/api/helpers/system_notifications.py 100.00% <ø> (ø)
...s/all/integration/api/helpers/test_notification.py 98.43% <98.43%> (ø)
app/api/helpers/notification.py 80.21% <100.00%> (+58.48%) ⬆️
app/models/notification.py 96.66% <0.00%> (+10.00%) ⬆️
app/api/helpers/log.py 82.75% <0.00%> (+20.68%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cea6494...aeac91f. Read the comment docs.

test_session = SessionFactory()
link = common.url_
event_name = common.string_
current_app.config['TESTING'] = False
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the send_notification isn't storing in db when app config is in TESTING mode

Copy link
Member

Choose a reason for hiding this comment

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

Then find the reason

user, invoice_id, order_url, event_name, subject_id
)
notif_ = Notification.query.all()
self.assertIsNotNone(notif_[0])
Copy link
Member

Choose a reason for hiding this comment

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

All tests should test the actual content of the notification as well

@iamareebjamal
Copy link
Member

@diru1100 Update?

@niranjan94
Copy link
Member

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- tests/all/integration/api/helpers/test_notification.py  2
         

See the complete overview on Codacy

@iamareebjamal iamareebjamal merged commit 41adf3e into fossasia:development May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write tests for notification functions
4 participants