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

Feature/tests #38

Merged
merged 28 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.0
current_version = 0.2.4

[bumpversion:file:setup.py]

Expand Down
6 changes: 6 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[run]
branch = True
omit = whatstk/tests/*

[report]
fail_under=80
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,8 @@ examples

#tox stuff
tox.ini
.coveragerc
#.coveragerc
requirements-flake.txt
requirements-test.txt
setup.cfg
testreport.html
testreport.xml
Expand All @@ -269,4 +268,5 @@ py37
*.ipynb

.pypirc
learn/
learn/
assets/style.css
23 changes: 14 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
dist: xenial
language: python
python:
- 3.7.2
- 3.8
- 3.5
- 3.7.2
- 3.8
before_install:
- pip install -r requirements-test.txt
install:
- pip install .
- ls -l
- pip uninstall whatstk
- pip install -e .
#pip install -r requirements.txt
script:
- pytest
- pip freeze | grep whatstk
- pytest --cov-report term --cov=whatstk tests/
after_success:
- codecov # submit coverage
deploy:
provider: pypi
user: lucasrodes
password:
secure: fqmlRL4Cbg8p+OolNSZW84I6iiIXKvrEcH5w2WSaQ1D+qO8b0+xMgLttypQ3vf+hFFc0K6HXHg9HNONFx8yP0/GNAKEl6gwk2ld3+JTM/rKAceVsoZlq6PwnoQqiityDGZHIg8pXVbKdccGQwWh1jvsMNQG3ACFpNZKHYjjESMSDtib9DsvqwdfwbUrjaM7Ucdvmw+ABeD4yDKgG1bU9pMnE+zdQe+9EsmFYY+K5FEdY6vre76BUadTl1MUn9mnUGi7bJHY+QXFxu23X5mvo7fPyII06Ss8lFcsJI/EjZlemr+aYTOXwKgUhfC+Rf3DGcEIRFNuPrq4WMUI7ox+ehE64L3Eved4jIlI1U+hWHitWT6FX+1xdg67lVPQqhbJN4vhhjJEz1+n55BkADp+zQ2UB/IfZbNgBNFtNf+NQYi87d2zNss+FP1Pg1qI0LsqwfroiLNfh2HBCMl6G5tjlU0OBbbiVsLxHxxk9i0uuDcp6FbCPwWZ/bUlj2EP+HPpuCYlzUQjySe+1T0WoGDx9ltXCQzHxiRPlU4i4q7EguMTLBG4vmA5HtYyOqEk0s5z5nsggYAu2ZTx5r3jmsQHElls5de96z4xDhNLMiz5IDngO/9niR65NhWEJXY8kEWubh+mQHvVDGl2rFC38ZwoGbs2+5Uq+Gzgp1b+byOoEc4E=
user: $USER_PYPI
password: $PWD_PYPI
on:
tags: true
tags: true
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include *.md
include LICENSE
include requirements.txt
include requirements-test.txt
include .coveragerc

recursive-include altair *.py *.json *.ipynb *.html
global-exclude *.py[co] __pycache__
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# [whatstk](http://lucasrodes.github.io/whatstk)

![Package version](https://img.shields.io/badge/whatstk-v0.2.0-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp)
![Package version](https://img.shields.io/badge/whatstk-v0.2.4-teal.svg?style=for-the-badge&color=25D366&logo=whatsapp)

[![Build Status](https://travis-ci.com/lucasrodes/whatstk.svg?branch=develop)](https://travis-ci.com/lucasrodes/whatstk)
[![Python 3.6](https://img.shields.io/badge/python-3.5|3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/)
[![codecov](https://codecov.io/gh/lucasrodes/whatstk/branch/master/graph/badge.svg)](https://codecov.io/gh/lucasrodes/whatstk)
[![Python 3.6](https://img.shields.io/badge/python-3.7|3.8-blue.svg)](https://www.python.org/downloads/release/python-3/)
[![Documentation](https://img.shields.io/badge/documentation-royalblue.svg)](docs/index.md)
[![GitHub license](https://img.shields.io/github/license/lucasrodes/whatstk.svg)](https://github.com/lucasrodes/whatstk/blob/master/LICENSE)
[![GitHub
license](https://img.shields.io/github/license/lucasrodes/whatstk.svg)](https://github.com/lucasrodes/whatstk/blob/master/LICENSE)


<!-- [![Downloads](https://pepy.tech/badge/whatstk)](https://pepy.tech/project/whatstk) -->
> [Get the Desktop App](https://lcsrg.me/whatstk-gui)

Expand All @@ -28,7 +32,7 @@ Make sure to first obtain the chat to be analyzed. Export it as a `txt` file usi

Check more on how-to use it in the [docs](docs/index.md)

#### Obtain a dataframe from your chat log file
### Obtain a dataframe from your chat log file

Load your chat using the object `WhatsAppChat`. Example below we use chat [example.txt](chats/example.txt)

Expand Down Expand Up @@ -68,7 +72,7 @@ header format. In our example, it would be: `hformat = '%d.%m.%y, %H:%M - %name:
_Note 2: If your chat uses 12h clock, it may not work as expected. If it is your case, please report it in the issues section._


#### Plot the cumulative messages sent by day
### Plot the cumulative messages sent by day
Once you have your `WhatsAppChat` object, you can easily get the number of interventions per user per, say, `day` using
the method `interventions()` with `date_mode` argument set to `'day'`. With this, some minor processing, `plotly` and `vis` method from `whatstk.plot` you can get really insightful plots.

Expand All @@ -86,7 +90,7 @@ plot(vis(counts_cumsum, 'cumulative number of messages sent per day'))

![](assets/example1.png)

### What's the header?
## What's the header?
The chat file syntax can differ between devices, OS and language settings, which makes it hard some times to correctly parse the data and make WhatsTK work correctly.

The header appears for each message sent in the chat. It contains a timestamp and the name of the user that sent the message.
Expand Down Expand Up @@ -149,6 +153,21 @@ header unit.
</tr>
</table>

## Known issues
- 12h clock header format is not supported.

## Contribute

We are very open to have collaborators. You can freely fork and issue a pull request with your updates!
For other issues/bugs/suggestions, please report it as an issue or [text me](mailto:lucasrg@kth.se).
For other issues/bugs/suggestions, please report it as an issue or [text me](mailto:lucasrg@kth.se).

###  Pull Requests
Make sure to test your code before issuing a pull request:

```
py.test --cov-report term --cov=whatstk tests/
```

_Note 1: Use `--html=testreport.html --cov-report html` to generate HTML reports._

However, pull requests will trigger the Travis CI pipeline, which will run the tests as well.
13 changes: 2 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* [parse\_chat](#.whatstk.utils.parser.parse_chat)
* [remove\_alerts\_from\_df](#.whatstk.utils.parser.remove_alerts_from_df)
* [whatstk.utils.exceptions](#.whatstk.utils.exceptions)
* [InterventionModeError](#.whatstk.utils.exceptions.InterventionModeError)
* [whatstk.objects](#.whatstk.objects)
* [WhatsAppChat](#.whatstk.objects.WhatsAppChat)
* [\_\_init\_\_](#.whatstk.objects.WhatsAppChat.__init__)
Expand Down Expand Up @@ -120,7 +119,7 @@ The unit of time can be chosen by means of argument `date_mode`.

**Raises**:

- `whatstk.exceptions.InterventionModeError` - if invalid mode is chosen.
- `ValueError` - if invalid mode is chosen.

<a name=".whatstk.core"></a>
## whatstk.core
Expand Down Expand Up @@ -254,15 +253,6 @@ Tries to get rid of alert/notification messages

Library exceptions.

<a name=".whatstk.utils.exceptions.InterventionModeError"></a>
### InterventionModeError

```python
class InterventionModeError(Exception)
```

Raised when a non-implemented mode is selected.

<a name=".whatstk.objects"></a>
## whatstk.objects

Expand Down Expand Up @@ -338,6 +328,7 @@ Get length of DataFrame
#### shape

```python
| @property
| def WhatsAppChat.shape()
```

Expand Down
4 changes: 3 additions & 1 deletion make-docs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Make sure to have pydoc-markdown:develop installed
# Make sure to have pydoc-markdown (develop branch) installed
# pip install git+https://github.com/NiklasRosenstein/pydoc-markdown.git@develop
#
# Then simply execute `sh make-docs.sh`

# Script to make documentation
mkdir -p docs
Expand Down
4 changes: 4 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pytest>=5.4.1
pytest-cov>=2.8.1
coverage>=4.5.1
codecov>=2.0.22
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pandas
numpy
plotly
pandas==1.0.3
numpy==1.18.2
plotly==4.5.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='whatstk',
version="0.2.0",
version="0.2.4",
description="Parser and analytics tools for WhatsApp group chats",
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions tests/chats/example_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[2016/04/15 15:04] You created group “Sample Group”
[2016/08/06 13:18] Messages you send to this group are now secured with end-to-end encryption. Tap for more info.
[2016/08/06 13:23] Ash Ketchum: Hey guys!
[2016/08/06 13:25] Brock: Hey Ash, good to have a common group!
[2016/08/06 13:30] Misty: Hey guys! Long time haven't heard anything from you
[2016/08/06 13:45] Ash Ketchum: Indeed. I think having a whatsapp group nowadays is a good idea
[2016/08/06 14:30] Misty: Definetly
[2016/08/06 17:25] Brock: I totally agree
[2016/08/07 11:45] Prof. Oak: Kids, shall I design a smart poke-ball?
[2016/08/07 18:45] Ash Ketchum: I don't mind Prof. I quitted capturing pokemon.
[2016/08/07 19:30] Misty: Was a great time, but had enough also.
[2016/08/07 23:25] Brock: Guys, I am still in the first gym. No one is playing pokemon, they went crazy with pokemon Go.
[2016/08/10 09:45] Jessie & James: Hey, thanks for adding us. Wanna meet soon? Just for the old times.
[2016/08/10 11:25] Raichu: I am in!
[2016/08/10 13:23] Ash Ketchum: FFS, no way, Pikachu did you evolve?
[2016/08/10 15:23] Raichu: Yes... Weird to have a different body!
[2016/08/11 19:30] Misty: Gotta see that.
[2016/09/11 20:25] Meowth: Hey people, I was on holidays in Sinnoh. Crazy region.
[2016/10/31 11:45] Prof. Oak: Smart-pokeball is created.
[2016/10/31 12:23] Wobbuffet: Wo-bbu-ffet

Loading