Skip to content

Commit

Permalink
Merge pull request #7 from caarmen/adapt-sleep-message
Browse files Browse the repository at this point in the history
Adapt sleep message
  • Loading branch information
caarmen authored May 14, 2023
2 parents fb76e89 + 72ee568 commit 4b858d0
Show file tree
Hide file tree
Showing 19 changed files with 1,252 additions and 27 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR check
on:
pull_request:
push:
branches:
- main
jobs:
PR:
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install -r requirements/dev.txt --upgrade pip
- name: Create fake .env file
run: cp .env.template .env
- name: Run codecheck
run: bash scripts/codecheck.sh
- name: Run tests
run: bash -x scripts/run_tests.sh
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: 'reports/junit.xml'
- name: Archive reports
if: always()
uses: actions/upload-artifact@v3
with:
name: reports
path: reports
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode
.env
.coverage
reports/
__pycache__/
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
log_cli=true
2 changes: 2 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-r prod.txt
ruff==0.0.263
black==23.3.0
pytest==7.3.1
pytest-cov==4.0.0
2 changes: 1 addition & 1 deletion scripts/codecheck.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for project in withingsslack alembic
for project in withingsslack alembic tests
do
black $project
ruff check $project
Expand Down
4 changes: 4 additions & 0 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rm -rf reports
python -m pytest --cov=withingsslack --cov-report=xml --cov-report=html --junitxml="reports/junit.xml" tests
mkdir -p reports
mv coverage.xml htmlcov reports/.
Empty file added tests/__init__.py
Empty file.
310 changes: 310 additions & 0 deletions tests/data/fitbit_sleep_response_1_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,310 @@
{
"sleep": [
{
"dateOfSleep": "2023-05-13",
"duration": 31620000,
"efficiency": 95,
"endTime": "2023-05-13T09:27:30.000",
"infoCode": 0,
"isMainSleep": true,
"levels": {
"data": [
{
"dateTime": "2023-05-13T00:40:00.000",
"level": "light",
"seconds": 60
},
{
"dateTime": "2023-05-13T00:41:00.000",
"level": "wake",
"seconds": 210
},
{
"dateTime": "2023-05-13T00:44:30.000",
"level": "deep",
"seconds": 1230
},
{
"dateTime": "2023-05-13T01:05:00.000",
"level": "light",
"seconds": 960
},
{
"dateTime": "2023-05-13T01:21:00.000",
"level": "deep",
"seconds": 1770
},
{
"dateTime": "2023-05-13T01:50:30.000",
"level": "light",
"seconds": 6180
},
{
"dateTime": "2023-05-13T03:33:30.000",
"level": "rem",
"seconds": 270
},
{
"dateTime": "2023-05-13T03:38:00.000",
"level": "light",
"seconds": 60
},
{
"dateTime": "2023-05-13T03:39:00.000",
"level": "wake",
"seconds": 450
},
{
"dateTime": "2023-05-13T03:46:30.000",
"level": "light",
"seconds": 360
},
{
"dateTime": "2023-05-13T03:52:30.000",
"level": "deep",
"seconds": 2520
},
{
"dateTime": "2023-05-13T04:34:30.000",
"level": "light",
"seconds": 360
},
{
"dateTime": "2023-05-13T04:40:30.000",
"level": "rem",
"seconds": 1980
},
{
"dateTime": "2023-05-13T05:13:30.000",
"level": "light",
"seconds": 3390
},
{
"dateTime": "2023-05-13T06:10:00.000",
"level": "rem",
"seconds": 1560
},
{
"dateTime": "2023-05-13T06:36:00.000",
"level": "light",
"seconds": 360
},
{
"dateTime": "2023-05-13T06:42:00.000",
"level": "rem",
"seconds": 2730
},
{
"dateTime": "2023-05-13T07:27:30.000",
"level": "light",
"seconds": 3780
},
{
"dateTime": "2023-05-13T08:30:30.000",
"level": "rem",
"seconds": 1050
},
{
"dateTime": "2023-05-13T08:48:00.000",
"level": "light",
"seconds": 1020
},
{
"dateTime": "2023-05-13T09:05:00.000",
"level": "wake",
"seconds": 1350
}
],
"shortData": [
{
"dateTime": "2023-05-13T01:48:00.000",
"level": "wake",
"seconds": 150
},
{
"dateTime": "2023-05-13T02:01:30.000",
"level": "wake",
"seconds": 120
},
{
"dateTime": "2023-05-13T02:13:30.000",
"level": "wake",
"seconds": 150
},
{
"dateTime": "2023-05-13T02:23:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T02:50:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T03:14:00.000",
"level": "wake",
"seconds": 60
},
{
"dateTime": "2023-05-13T03:32:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T04:33:00.000",
"level": "wake",
"seconds": 90
},
{
"dateTime": "2023-05-13T04:38:00.000",
"level": "wake",
"seconds": 60
},
{
"dateTime": "2023-05-13T04:53:30.000",
"level": "wake",
"seconds": 60
},
{
"dateTime": "2023-05-13T05:01:00.000",
"level": "wake",
"seconds": 60
},
{
"dateTime": "2023-05-13T05:07:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T05:15:00.000",
"level": "wake",
"seconds": 120
},
{
"dateTime": "2023-05-13T05:22:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T06:13:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T06:19:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T06:29:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T06:47:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T07:01:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T07:09:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T07:15:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T07:30:00.000",
"level": "wake",
"seconds": 120
},
{
"dateTime": "2023-05-13T07:43:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T08:24:30.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T08:28:30.000",
"level": "wake",
"seconds": 60
},
{
"dateTime": "2023-05-13T08:35:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T08:46:00.000",
"level": "wake",
"seconds": 30
},
{
"dateTime": "2023-05-13T08:48:30.000",
"level": "wake",
"seconds": 180
},
{
"dateTime": "2023-05-13T08:58:00.000",
"level": "wake",
"seconds": 30
}
],
"summary": {
"deep": {
"count": 3,
"minutes": 88,
"thirtyDayAvgMinutes": 87
},
"light": {
"count": 25,
"minutes": 258,
"thirtyDayAvgMinutes": 268
},
"rem": {
"count": 17,
"minutes": 119,
"thirtyDayAvgMinutes": 96
},
"wake": {
"count": 32,
"minutes": 62,
"thirtyDayAvgMinutes": 57
}
}
},
"logId": 41314291715,
"logType": "auto_detected",
"minutesAfterWakeup": 0,
"minutesAsleep": 465,
"minutesAwake": 62,
"minutesToFallAsleep": 0,
"startTime": "2023-05-13T00:40:00.000",
"timeInBed": 527,
"type": "stages"
}
],
"summary": {
"stages": {
"deep": 88,
"light": 258,
"rem": 119,
"wake": 62
},
"totalMinutesAsleep": 465,
"totalSleepRecords": 1,
"totalTimeInBed": 527
}
}
Loading

0 comments on commit 4b858d0

Please sign in to comment.