-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sakethramanujam/v0.3-dev
v0.3
- Loading branch information
Showing
7 changed files
with
182 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Client Tests | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
- name: Install dependencies and test | ||
env: | ||
working-directory: cpcbccr-python-client | ||
run: | | ||
python -m pip install --upgrade pip | ||
python setup.py install | ||
pip install pytest | ||
pytest tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import cpcbccr as cpcb | ||
import pandas as pd | ||
import pytest | ||
|
||
expected_data = {'from date': {0: '01-Jan-2020 - 00:00'}, | ||
'AT': {0: '15.57'}, | ||
'BP': {0: '732.58'}, | ||
'Benzene': {0: '8.03'}, | ||
'NO': {0: '21.52'}, | ||
'NO2': {0: '59.95'}, | ||
'NOx': {0: '30.89'}, | ||
'Ozone': {0: '28.57'}, | ||
'PM2.5': {0: '274.89'}, | ||
'RH': {0: '76.24'}, | ||
'SO2': {0: '17.72'}, | ||
'SR': {0: '58.18'}, | ||
'Toluene': {0: '15.94'}, | ||
'VWS': {0: '-1.33'}, | ||
'WD': {0: '188.71'}, | ||
'WS': {0: '0.76'}, | ||
'Xylene': {0: '9.93'}, | ||
'to date': {0: '02-Jan-2020 - 00:00'}} | ||
|
||
|
||
def test_get_data_success(): | ||
data = cpcb.get_data(from_date='01-01-2020', to_date='01-01-2020', | ||
criteria='24 Hours', station_id='site_273') | ||
assert data.to_dict() == expected_data | ||
|
||
|
||
def test_get_data_failure(): | ||
with pytest.raises(Exception): | ||
cpcb.get_data(from_date='01-01-2020', | ||
criteria='24 Hours', station_id='site_273') | ||
|
||
with pytest.raises(Exception): | ||
cpcb.get_data(to_date='01-01-2020', | ||
criteria='24 Hours', station_id='site_273') | ||
with pytest.raises(Exception): | ||
cpcb.get_data(from_date='01-01-2020', to_date='01-01-2020', | ||
criteria='24 Hours') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import cpcbccr as cpcb | ||
import pytest | ||
|
||
|
||
def test_get_states(): | ||
states = cpcb.get_states() | ||
assert len(states) > 0 | ||
|
||
|
||
def test_get_cities_success(): | ||
cities = cpcb.get_cities('Assam') | ||
assert cities == ['Guwahati'] | ||
|
||
|
||
def test_get_cities_failure(): | ||
with pytest.raises(Exception): | ||
cpcb.get_cities('qwerty') | ||
|
||
|
||
def test_get_stations_success(): | ||
stations = cpcb.get_stations('Guwahati') | ||
assert stations == [{'id': 'site_5073', | ||
'live': True, | ||
'name': 'Railway Colony, Guwahati - APCB'}] | ||
|
||
|
||
def test_get_stations_failure(): | ||
with pytest.raises(Exception): | ||
cpcb.get_stations('qwerty') |