Skip to content

Commit

Permalink
Upgrade to Github Actions + Python version bump (#244)
Browse files Browse the repository at this point in the history
* Upgrade to Github Actions + Python version bump

* Fix tests
  • Loading branch information
inverse authored Jul 26, 2022
1 parent fcd7abd commit 8316165
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 16 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Main

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10', '3.9', '3.8', '3.7']
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements-test.txt
- name: Test
run: python -m pytest test.py
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install -r requirements-test.txt
- name: Lint
run: flake8 haaska.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ build
.DS_Store
haaska.zip
/.vs
/.idea/
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6
FROM python:3.10

RUN \
apt-get update && \
Expand All @@ -10,7 +10,8 @@ RUN \

RUN mkdir -p /usr/src/app

COPY . /usr/src/app
WORKDIR /usr/src/app

COPY . /usr/src/app

CMD ["make"]
2 changes: 1 addition & 1 deletion haaska.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3.6
#!/usr/bin/env python
# coding: utf-8

# Copyright (c) 2015 Michael Auchter <a@phire.org>
Expand Down
3 changes: 3 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-r requirements.txt
pytest==7.1.2
flake8==4.0.1
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pytest==5.1.2
requests==2.22.0
requests==2.22.0
10 changes: 8 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from haaska import HomeAssistant, Configuration


@pytest.fixture
def configuration():
return Configuration(opts_dict={
Expand All @@ -13,24 +14,29 @@ def configuration():
"ssl_client": []
})


@pytest.fixture
def home_assistant(configuration):
return HomeAssistant(configuration)


def test_ha_build_url(home_assistant):
url = home_assistant.build_url("test")
assert url == "http://localhost:8123/api/test"


def test_get_user_agent(home_assistant):
os.environ["AWS_DEFAULT_REGION"] = "test"
user_agent = home_assistant.get_user_agent()
assert user_agent.startswith("Home Assistant Alexa Smart Home Skill - test - python-requests/")


def test_config_get(configuration):
assert configuration.get(["debug"]) == False
assert configuration.get(["test"]) == None
assert configuration.get(["debug"]) is False
assert configuration.get(["test"]) is None
assert configuration.get(["test"], default="default") == "default"


def test_config_get_url(configuration):
test_urls = [
"http://hass.example.com:8123",
Expand Down

0 comments on commit 8316165

Please sign in to comment.