Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
[AP-867] Make unit tests to work (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
koszti authored Oct 21, 2020
1 parent 4d94472 commit fe0432f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 195 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ jobs:
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install .[test]
pip install .[test] --use-feature=2020-resolver
- run:
name: 'Pylinting'
command: |
. venv/bin/activate
pylint tap_slack -d C,W,unexpected-keyword-arg,duplicate-code,too-many-arguments,too-many-locals,too-many-nested-blocks,useless-object-inheritance,no-self-argument,raising-non-exception,no-member
- run:
name: 'Unit Tests'
command: echo "No unit tests :("
command: |
. venv/bin/activate
pytest tests
workflows:
version: 2
Expand Down
47 changes: 8 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,47 +189,16 @@ The `Users` stream _does_ store information about when a User record was last up
- API Documentation: [Link](https://api.slack.com/methods/files.remote.list)

## Testing the Tap

While developing the Slack tap, the following utilities were run in accordance with Singer.io best practices:
Pylint to improve [code quality](https://github.com/singer-io/getting-started/blob/master/docs/BEST_PRACTICES.md#code-quality):
```bash
> pylint tap_slack -d missing-docstring -d logging-format-interpolation -d too-many-locals -d too-many-arguments
```
Pylint test resulted in the following score:
```bash
Your code has been rated at 9.72/10

Install test dependencies
```bash
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
pip install .[test]
```

To [check the tap](https://github.com/singer-io/singer-tools#singer-check-tap) and verify working:
To run tests:
```bash
> tap-slack --config tap_config.json --catalog catalog.json | singer-check-tap > state.json
> tail -1 state.json > state.json.tmp && mv state.json.tmp state.json
```
Check tap resulted in the following:
```bash
Checking stdin for valid Singer-formatted data
The output is valid.
It contained 3657 messages for 9 streams.

581 schema messages
2393 record messages
683 state messages

Details by stream:
+-----------------+---------+---------+
| stream | records | schemas |
+-----------------+---------+---------+
| threads | 633 | 573 |
| user_groups | 1 | 1 |
| channel_members | 1049 | 1 |
| users | 22 | 1 |
| channels | 0 | 1 |
| remote_files | 3 | 1 |
| messages | 573 | 1 |
| teams | 1 | 1 |
| files | 111 | 1 |
+-----------------+---------+---------+
pytest
```
----
Copyright © 2019 Stitch
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
extras_require={
'test': [
'pylint',
'ipdb',
'nose'
'pytest'
]
},
python_requires='>=3.6',
Expand Down
33 changes: 0 additions & 33 deletions tests/test_configuration.py

This file was deleted.

23 changes: 23 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import singer
import jsonschema

class TestSchemas:
""" Test schemas """
schemas_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'tap_slack', 'schemas'))

def get_schemas(self):
"""Function to get all json schema paths"""
schemas = []
for f in os.listdir(self.schemas_dir):
if os.path.isfile(os.path.join(self.schemas_dir, f)):
if '.json' in f:
schemas.append(os.path.join(self.schemas_dir, f))

return schemas

def test_schemas(self):
"""Check if every schema is a valid JSON Schema"""
for schema in self.get_schemas():
s = singer.utils.load_json(schema)
assert jsonschema.Draft7Validator(s).check_schema(s) is None
119 changes: 0 additions & 119 deletions tests/test_sync.py

This file was deleted.

0 comments on commit fe0432f

Please sign in to comment.