Skip to content

Latest commit

 

History

History
82 lines (56 loc) · 2.12 KB

File metadata and controls

82 lines (56 loc) · 2.12 KB

robotframework-devicelibrary

Robot Framework Library for creating and interacting with devices using various adapters such as ssh, docker and local devices using the same interface.

Using it

  1. Install via pip

    pip install robotframework-devicelibrary[all]  git+https://github.com/reubenmiller/robotframework-devicelibrary.git@0.24.4

    Or add it to your requirements.txt file

    robotframework-devicelibrary[all] @ git+https://github.com/reubenmiller/robotframework-devicelibrary.git@0.24.4

    Then install it via

    pip install -r requirements.txt
  2. Create a .env file with the following environment variables (which will be the secrets)

    # SSH config (which device should be tested when using ssh)
    SSH_CONFIG_HOSTNAME=
    SSH_CONFIG_USERNAME=
    SSH_CONFIG_PASSWORD=
  3. Create a common resource which contains your settings tests/common.resource

    ${DEVICE_ADAPTER}    docker
    &{SSH_CONFIG}        hostname=%{SSH_CONFIG_HOSTNAME= }    username=%{SSH_CONFIG_USERNAME= }    password=%{SSH_CONFIG_PASSWORD= }
    &{DOCKER_CONFIG}     image=%{DOCKER_CONFIG_IMAGE=debian-systemd}

    Note

    The common resource references the secrets stored in the .env file so secrets can be kept out of the repository.

  4. Create a Robot test tests/Example.robot

    *** Settings ***
    Resource       common.resource
    Library        DeviceLibrary    adapter=ssh
    
    *** Test Cases ***
    Check command execution
        Setup Device
        Execute Command On Device    ls -la /etc/
        Process Should Be Running On Device    ssh
  5. Run the test

    robot tests/Example.robot

Library docs

Checkout the DeviceLibrary docs

You can generate the docs yourself using:

libdoc DeviceLibrary/DeviceLibrary.py show > docs/DeviceLibrary.rst

Or you can create the html docs using:

libdoc ./DeviceLibrary/DeviceLibrary.py docs/DeviceLibrary.html

Then open the docs/DeviceLibrary.html file in your local web browser.