Skip to content

Commit

Permalink
Feature/wrap up 1.1.1 release (#20)
Browse files Browse the repository at this point in the history
* Docs and Prints

- removed stray print statements
- fixed type in documentation
- starting to prep for the V1.1.1 release

* Testing

- added some basic tests to the write api.

* Docs

- even more doc updates. added some UML
- updated the main readme

* sphinx

- updated the sphinx docs
  • Loading branch information
carlkidcrypto authored Sep 22, 2023
1 parent 7ed3004 commit 5522c0b
Show file tree
Hide file tree
Showing 26 changed files with 92 additions and 20 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Now you can use that PAA instance to do things like...
retval = my_paa.request_sensor_data(1234)
```

> Note: PurpleAirAPI is the main entry point. It will load read, write, and local submodules
based on the parameters that are passed in upon construction. If you wish to only use a
small piece of PurpleAirAPI then see the examples below.

## PurpleAirReadAPI Usage Example

First we need to import the PurpleAirReadAPI.
Expand Down
9 changes: 9 additions & 0 deletions diagrams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Diagrams

This directory contains design diagrams.

## Auto Generate UML

```bash
pyreverse -d . -o png ../purpleair_api
```
Binary file added diagrams/classes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added diagrams/packages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/doctrees/environment.pickle
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 0e3dd2b003b323d457484d3d023fbd15
config: 0e51ed3cfc03ba99e6a14e4a6722ae86
tags: 645f666f9bcd5a90fca523b33c5a78b7
2 changes: 1 addition & 1 deletion docs/html/PurpleAirAPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirAPI module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirAPI module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/PurpleAirAPIConstants.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirAPIConstants module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirAPIConstants module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/PurpleAirAPIError.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirAPIError module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirAPIError module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/PurpleAirAPIHelpers.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirAPIHelpers module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirAPIHelpers module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/PurpleAirLocalAPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirLocalAPI module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirLocalAPI module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/PurpleAirReadAPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirReadAPI module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirReadAPI module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/PurpleAirWriteAPI.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PurpleAirWriteAPI module &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>PurpleAirWriteAPI module &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: 'V1.1.1a0',
VERSION: 'V1.1.1',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
2 changes: 1 addition & 1 deletion docs/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>Index &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Welcome to PurpleAirAPI’s documentation! &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>Welcome to PurpleAirAPI’s documentation! &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>purpleair_api &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>purpleair_api &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Module Index &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>Python Module Index &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &mdash; PurpleAir API V1.1.1a0 documentation</title>
<title>Search &mdash; PurpleAir API V1.1.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />

Expand Down
2 changes: 1 addition & 1 deletion docs/html/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion purpleair_api/PurpleAirAPIConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"pm2.5_cf_1_b": 0.0,
# PM2.5 pseudo (simple running) average fields:
# Note: These are inside the return json as json["sensor"]["stats"]. They are averages of the two sensors.
# sensor 'a' and 'b' sensor be. Each sensors data is inside json["sensor"]["stats_a"] and json["sensor"]["stats_b"]
# sensor 'a' and sensor 'b'. Each sensors data is inside json["sensor"]["stats_a"] and json["sensor"]["stats_b"]
"pm2.5_10minute": 0.0,
"pm2.5_10minute_a": 0.0,
"pm2.5_10minute_b": 0.0,
Expand Down
2 changes: 0 additions & 2 deletions purpleair_api/PurpleAirLocalAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def request_local_sensor_data(self) -> dict:

retval = {}
for key, value in self._base_api_local_network_request_string_dict.items():
print("key", key)
print("value", value)
request_value = send_url_get_request(value)
retval[key] = request_value

Expand Down
1 change: 1 addition & 0 deletions purpleair_api/PurpleAirWriteAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PurpleAirWriteAPI:
def __init__(self, api_write_key=None):
# Save off the API key for internal usage
self._your_api_write_key = api_write_key
self._base_api_v1_request_string = "https://api.purpleair.com/v1/"

def post_create_group_data(self, name):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def read_file(filename):

setup(
name="purpleair_api",
version="1.1.1a0",
version="1.1.1",
license="MIT",
author="Carlos Santos",
author_email="dose.lucky.sake@cloak.id",
Expand Down
2 changes: 1 addition & 1 deletion sphinx_docs_build/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "carlkidcrypto"

# The full version, including alpha/beta/rc tags
release = "V1.1.1a0"
release = "V1.1.1"


# -- General configuration ---------------------------------------------------
Expand Down
60 changes: 60 additions & 0 deletions test/test_purpleair_write_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python3

"""
Copyright 2023 carlkidcrypto, All rights reserved.
"""


import unittest
import requests_mock
import sys

sys.path.append("../")

from purpleair_api.PurpleAirWriteAPI import PurpleAirWriteAPI


class PurpleAirWriteAPITest(unittest.TestCase):
def setUp(self):
self.pala = PurpleAirWriteAPI(123456789)

def tearDown(self):
self.pala = None

def test_post_create_group_data(self):
"""
Test that we can post to create a group for sensors.
"""

# Setup
fake_url_request = "https://api.purpleair.com/v1/groups"

# Action and Expected Result
with requests_mock.Mocker() as m:
m.post(
fake_url_request,
text='{"test" : 1234}',
status_code=200,
)
self.pala.post_create_group_data("this_is_a_name")

def test_post_create_member_with_sensor_index(self):
"""
Test that we can post to add members to a sensor group.
"""

# Setup
fake_url_request = "https://api.purpleair.com/v1/groups/1234/members"

# Action and Expected Result
with requests_mock.Mocker() as m:
m.post(
fake_url_request,
text='{"test" : 1234}',
status_code=200,
)
self.pala.post_create_member(group_id=1234, sensor_index=4567)


if __name__ == "__main__":
unittest.main()

0 comments on commit 5522c0b

Please sign in to comment.