MrYsLab / pymata-aio

This is the second generation PyMata client.
https://github.com/MrYsLab/pymata-aio/wiki
GNU Affero General Public License v3.0
155 stars 51 forks source link

How can I make a unit test for board connection? #63

Closed JosephMart closed 6 years ago

JosephMart commented 6 years ago

How do you suggest that I create a unit test for validation a proper connection to an Arduino board?

MrYsLab commented 6 years ago

There are 2 possibilities to test for:

  1. The board is not plugged.
  2. The board is plugged in, but the incorrect sketch is loaded on Arduino.

Is this what you are looking for?

import asyncio
from pymata_aio.pymata3 import PyMata3

def test_connection():
    try:
        board = PyMata3()
    # Board not plugged in - correct sketch or not
    except TypeError:
        assert False
    # incorrect sketch loaded
    except asyncio.futures.CancelledError:
        assert False
JosephMart commented 6 years ago

Yep this is what I wanted. Thanks!