Skip to content

Commit b77aa54

Browse files
Merge pull request #7 from Lash-L/pytest
Adding some basic pytest
2 parents 2fdfe1d + 0e27228 commit b77aa54

File tree

10 files changed

+669
-3
lines changed

10 files changed

+669
-3
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
concurrency:
10+
group: ${{ github.head_ref || github.run_id }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version:
19+
- "3.10"
20+
- "3.11"
21+
os:
22+
- ubuntu-latest
23+
- windows-latest
24+
- macOS-latest
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Set up Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
- uses: snok/install-poetry@v1.3.3
33+
- name: Install Dependencies
34+
run: poetry install
35+
shell: bash
36+
- name: Test with Pytest
37+
run: poetry run pytest
38+
shell: bash

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ venv
44
.idea
55
roborock/__pycache__
66
poetry.lock
7+
*.pyc
8+
.coverage

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ packages = [{include = "roborock"}]
1111
roborock = "roborock.cli:main"
1212

1313
[tool.poetry.dependencies]
14-
python = "^3.8"
14+
python = "^3.9"
1515
click = ">=8"
1616
aiohttp = "*"
1717
async-timeout = "*"
@@ -24,3 +24,7 @@ paho-mqtt = "~1.6.1"
2424
requires = ["poetry-core"]
2525
build-backend = "poetry.core.masonry.api"
2626

27+
[tool.poetry.dev-dependencies]
28+
pytest-asyncio = "*"
29+
pytest = "*"
30+

roborock/roborock_queue.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import asyncio
21
from asyncio import Queue
32
from typing import Any
43
import async_timeout
@@ -7,7 +6,6 @@
76

87

98
class RoborockQueue(Queue):
10-
119
def __init__(self, protocol: int, *args):
1210
super().__init__(*args)
1311
self.protocol = protocol

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import pytest
2+
3+
from roborock import RoborockMqttClient, UserData, HomeData, RoborockDeviceInfo
4+
from tests.mock_data import USER_DATA, HOME_DATA_RAW
5+
6+
7+
@pytest.fixture(name="mqtt_client")
8+
def mqtt_client():
9+
user_data = UserData(USER_DATA)
10+
home_data = HomeData(HOME_DATA_RAW)
11+
device = RoborockDeviceInfo(home_data.devices[0], home_data.products[0])
12+
device_map = {home_data.devices[0].duid: device}
13+
client = RoborockMqttClient(user_data, device_map)
14+
yield client
15+
# Clean up any resources after the test

0 commit comments

Comments
 (0)