Giter Club home page Giter Club logo

appdaemon-testing's Introduction

Hey ๐Ÿ‘‹

I'm Nick, A frontend engineer at Canva. I love complex problems and challenges, and things that give me something new and interesting to work on.

As might be apparent from my numerous home automation repositories, in my free time I enjoy dabbling in home automation. I'm a huge evangelist of Home Assistant and run it at a few different physical sites.

On the side I run 100 Warm Tunas, an social aggregation site, intended to predict triple j's Hottest 100 each year.

See my latest work at my website, https://nickwhyte.com

appdaemon-testing's People

Contributors

dependabot[bot] avatar nickw444 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

appdaemon-testing's Issues

Should a setup state also pass an assertion?

Thanks for making this code available. Very useful indeed.

I am new to python/appdaemon testing and was debugging a test case, but should the commented out assertions below not return true? If I comment the line out it passes okay.

test code

from appdaemon_testing.pytest import automation_fixture
from appdaemon_testing.pytest import mock
from apps.automation import Automation

@automation_fixture(
    Automation,
    args={
    },
)

def automation() -> Automation:
    pass

...
def test_not_is_dusk(hass_driver, automation: Automation):
    with hass_driver.setup():
        hass_driver.set_state('sun.sun', 0, attribute_name='elevation')
    # assert automation.get_state('sun.sun', attribute_name='elevation') == 0 # <<<<<<<<<<<<<<<<<<<<<<
    assert not automation.is_dusk()

def test_is_dusk(hass_driver, automation: Automation):
    with hass_driver.setup():
        hass_driver.set_state('sun.sun', -4, attribute_name='elevation')
    # assert automation.get_state('sun.sun', attribute_name='elevation') == -4 # <<<<<<<<<<<<<<<<<<<<<<
    assert automation.is_dusk()

code under test

class Automation(hass.Hass):
...
    def get_sun_elevation(self):
        elev = self.get_state('sun.sun', attribute='elevation')
        self.log(f'   elev ({elev:2.2f})', level='DEBUG')
        return elev

    def is_dusk(self):
        elev = self.get_sun_elevation()
        dusk = elev < -3
        t = 'is' if dusk else 'is not'
        self.log(f'   {t} dusk', level='DEBUG')
        return dusk
...

Is there a way to test asyncio apps?

Hi there,

really interested in this lib, looks great!
However, all of my appdaemon apps are written in asyncio "syntax".
Is there a way to test those with your lib as well?

Thx!

Feature Request: Unit Test for AppDaemon

Hello @nickw444,

Thanks for this framework. I am one of the maintainers for AD, and wanted to ask if there was a way for you to kindly extend your framework to be used to test AD as a whole and not just apps (well I kind of recognise its one and the same thing anyway), nor limited to the Hass namespace.

Basically we looking at having a CI/CD pipeline going forward, so every code blocks to be merged can be automatically tested to check for non breaking code before the PR is accepted; mind you this is not something I have done before, so apologies ahead if I missed something.

Is this something you can help us with please? The target for now will be mostly the general apis, then over time we can expand into specific plugin based apis.

Kind regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.