Skip to content

Commit

Permalink
Trying out codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
jsga committed Feb 1, 2020
1 parent 544d4dc commit 87dcfde
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 35 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ install:
- pip install -r requirements_dev.txt
- pip install .
# command to run tests
script: make test
script:
- make test
- py.test --cov-report=xml --cov=bundle_notifications --cov=tests/
after_success:
- codecov
67 changes: 34 additions & 33 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. highlight:: shell

====================
bundle_notifications
====================
Expand All @@ -11,51 +13,50 @@ bundle_notifications
:alt: Documentation Status



Features
---------

This package contains a tool for bundling notifications in event streams. The goal is to minimize the number of notifications sent to users.

As an example, here it is the first couple of rows for a sample user_id:

=================== ============================== ============================== =============
timestamp user_id friend_id friend_name
=================== ============================== ============================== =============
2017-08-08 11:04:36 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor
2017-08-10 12:29:47 0005BDD51B0185DCF1A4932CEB8437 266C5C5239255DF65ECFFDCEAF7048 Iustinian
2017-08-11 11:53:12 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor
2017-08-12 23:42:11 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara
2017-08-24 14:49:06 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor
2017-08-31 14:30:48 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara
2017-09-01 13:21:59 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie
2017-09-01 13:29:40 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie
2017-09-01 17:13:37 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie
2017-09-26 13:02:32 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara
=================== ============================== ============================== =============
As an example, here it is the first couple of rows for a sample user_id::

=================== ============================== ============================== =============
timestamp user_id friend_id friend_name
=================== ============================== ============================== =============
2017-08-08 11:04:36 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor
2017-08-10 12:29:47 0005BDD51B0185DCF1A4932CEB8437 266C5C5239255DF65ECFFDCEAF7048 Iustinian
2017-08-11 11:53:12 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor
2017-08-12 23:42:11 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara
2017-08-24 14:49:06 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor
2017-08-31 14:30:48 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara
2017-09-01 13:21:59 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie
2017-09-01 13:29:40 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie
2017-09-01 17:13:37 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie
2017-09-26 13:02:32 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara
=================== ============================== ============================== =============

Using bundle_notifications tool, we get the following DataFrame with 3 new columns:

1. **tours**: number of friends that have gone on a tour since the beginning of the stream of data
2. **timestamp_first_tour**: timestamp for the first tour amongst his/her friends
3. **message**: notification message

Here it is the outcome:

=================== ============================== ============================== ============= ======= ====================== =====================================
timestamp user_id friend_id friend_name tours timestamp_first_tour message
=================== ============================== ============================== ============= ======= ====================== =====================================
2017-08-08 11:04:36 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor 1 2017-08-08 11:04:36 Rameshwor went on a tour
2017-08-10 12:29:47 0005BDD51B0185DCF1A4932CEB8437 266C5C5239255DF65ECFFDCEAF7048 Iustinian 2 2017-08-08 11:04:36 Rameshwor and 1 other went on a tour
2017-08-11 11:53:12 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor 2 2017-08-08 11:04:36 Rameshwor and 1 other went on a tour
2017-08-12 23:42:11 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara 3 2017-08-08 11:04:36 Rameshwor and 2 others went on a tour
2017-08-24 14:49:06 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor 3 2017-08-08 11:04:36 Rameshwor and 2 others went on a tour
2017-08-31 14:30:48 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara 3 2017-08-08 11:04:36 Rameshwor and 2 others went on a tour
2017-09-01 13:21:59 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
2017-09-01 13:29:40 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
2017-09-01 17:13:37 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
2017-09-26 13:02:32 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
=================== ============================== ============================== ============= ======= ====================== =====================================
Here it is the outcome::

=================== ============================== ============================== ============= ======= ====================== =====================================
timestamp user_id friend_id friend_name tours timestamp_first_tour message
=================== ============================== ============================== ============= ======= ====================== =====================================
2017-08-08 11:04:36 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor 1 2017-08-08 11:04:36 Rameshwor went on a tour
2017-08-10 12:29:47 0005BDD51B0185DCF1A4932CEB8437 266C5C5239255DF65ECFFDCEAF7048 Iustinian 2 2017-08-08 11:04:36 Rameshwor and 1 other went on a tour
2017-08-11 11:53:12 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor 2 2017-08-08 11:04:36 Rameshwor and 1 other went on a tour
2017-08-12 23:42:11 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara 3 2017-08-08 11:04:36 Rameshwor and 2 others went on a tour
2017-08-24 14:49:06 0005BDD51B0185DCF1A4932CEB8437 0B56C34B2BB9B80100D1D5B5AB74EA Rameshwor 3 2017-08-08 11:04:36 Rameshwor and 2 others went on a tour
2017-08-31 14:30:48 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara 3 2017-08-08 11:04:36 Rameshwor and 2 others went on a tour
2017-09-01 13:21:59 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
2017-09-01 13:29:40 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
2017-09-01 17:13:37 0005BDD51B0185DCF1A4932CEB8437 DACE6D3C78D9B20B1F70A271BA98D5 Julie 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
2017-09-26 13:02:32 0005BDD51B0185DCF1A4932CEB8437 FB63F29610B1EF67AD75C4BABDFCE1 Sara 4 2017-08-08 11:04:36 Rameshwor and 3 others went on a tour
=================== ============================== ============================== ============= ======= ====================== =====================================

Note that Julie went on 3 tours in a row. The tool takes this into account this, so that Julie's friend receive a single notification that Julie went on a tour.

Expand Down
2 changes: 2 additions & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bump2version==0.5.11
certifi==2019.11.28
chardet==3.0.4
Click==7.0
codecov==2.0.15
coverage==4.5.4
docutils==0.16
entrypoints==0.3
Expand All @@ -32,6 +33,7 @@ pyflakes==2.1.1
Pygments==2.5.2
pyparsing==2.4.6
pytest==4.6.5
pytest-cov==2.8.1
pytest-runner==5.1
python-dateutil==2.8.1
pytz==2019.3
Expand Down
4 changes: 3 additions & 1 deletion tests/test_bundle_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ def test_bundle_func():
def test_add_message():
"""Test for the message of the notification"""

x = pd.DataFrame({'message':['Javi','Javier', 'Saez'], 'tours':[1,2,3]})
x = pd.DataFrame({'message':['Javi','Javier', 'Saez','Gallego'], 'tours':[1,2,3,-1]})

assert bundle_notifications.add_message(x.iloc[0,]) == 'Javi went on a tour'
assert bundle_notifications.add_message(x.iloc[1,]) == 'Javier and 1 other went on a tour'
assert bundle_notifications.add_message(x.iloc[2,]) == 'Saez and 2 others went on a tour'
with pytest.raises(ValueError):
bundle_notifications.add_message(x.iloc[3,])

0 comments on commit 87dcfde

Please sign in to comment.