Skip to content
Open
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore everything
**

# ... except for dependencies and source
!Pipfile
!Pipfile.lock
!src/
!.env
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
name: Doc
about: Documentation needs
title: Documentation
labels: ''
assignees: ''

---
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
38 changes: 38 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

**Test Configuration**:
* Firmware version:
* Hardware:
* Toolchain:
* SDK:

# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ deploy_rsa
deploy_rsa.pub

# Kubernetes config
kubeconfig.yaml
kubeconfig.yaml
27 changes: 26 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
## To implement
repos:
- repo: https://github.com/PyCQA/pylint
rev: v3.0.0a6
hooks:
- id: pylint
args: [--rcfile=.pylintrc]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: local
hooks:
- id: run-unit-tests
name: Run Unit Tests
entry: "docker buildx build -t oxygen-tests -f Dockerfile.tests . --output type=docker --rm"
language: system
pass_filenames: false
types: [python]
2 changes: 2 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MASTER]
disable=missing-docstring,invalid-name,import-error,broad-except,unused-argument,unused-variable,too-few-public-methods
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
## To implement
FROM python:3.8

RUN pip install pipenv

WORKDIR /usr/src/app

COPY . .

RUN pipenv install --dev

CMD [ "pipenv", "run", "start" ]
11 changes: 11 additions & 0 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.8 AS development

RUN pip install pipenv

WORKDIR /usr/src/app

COPY . .

RUN pipenv install --dev

CMD ["pytest", "test.py"]
6 changes: 4 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ requests = "*"
signalrcore = "*"

[dev-packages]
pylint = "*"
black = "*"
pre-commit = "*"
pytest = "*"

[requires]
python_version = "3.8"

[scripts]
start = "python src/main.py"
test = "# To implement"
lint = "# To implement"
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ MIT
## Contact

For more information, please feel free to contact the repository owner.

## Docker

```
docker pull python:3.8
docker build -t oxygen-cs .
docker run -it --rm --name oxygen-cs oxygen-cs
```
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: '3.8'
services:
app:
build: .
ports:
- "8000:8000"
networks:
- network
environment:
- PYTHONUNBUFFERED=1

networks:
network:
name: postgres_network
external: true
12 changes: 7 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from signalrcore.hub_connection_builder import HubConnectionBuilder
import logging
import requests
import json
import time
from signalrcore.hub_connection_builder import HubConnectionBuilder
import requests


class Main:
Expand All @@ -16,7 +16,7 @@ def __init__(self):
self.DATABASE = None # Setup your database here

def __del__(self):
if self._hub_connection != None:
if self._hub_connection is not None:
self._hub_connection.stop()

def setup(self):
Expand Down Expand Up @@ -49,14 +49,16 @@ def setSensorHub(self):
self._hub_connection.on("ReceiveSensorData", self.onSensorDataReceived)
self._hub_connection.on_open(lambda: print("||| Connection opened."))
self._hub_connection.on_close(lambda: print("||| Connection closed."))
self._hub_connection.on_error(lambda data: print(f"||| An exception was thrown closed: {data.error}"))
self._hub_connection.on_error(
lambda data: print(f"||| An exception was thrown closed: {data.error}")
)

def onSensorDataReceived(self, data):
try:
print(data[0]["date"] + " --> " + data[0]["data"])
date = data[0]["date"]
dp = float(data[0]["data"])
self.send_temperature_to_fastapi(date, dp)
# DNE self.send_temperature_to_fastapi(date, dp)
self.analyzeDatapoint(date, dp)
except Exception as err:
print(err)
Expand Down
32 changes: 31 additions & 1 deletion test/test.py
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
## To Implement
import unittest
from unittest.mock import MagicMock


# The class we want to test
class Calculator:
def add(self, x, y):
return x + y


# The unit test class
class TestCalculator(unittest.TestCase):
def test_add(self):
# Create an instance of the Calculator class
calculator = Calculator()

# Create a mock object for the add method
calculator.add = MagicMock(return_value=10)

# Call the add method with some values
result = calculator.add(2, 3)

# Verify that the add method was called with the correct arguments
calculator.add.assert_called_once_with(2, 3)

# Verify that the result is as expected
self.assertEqual(result, 10)


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