From 20bbfcbe3ff5b5d441298a4cef37b34754d85b35 Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Tue, 21 Jul 2015 15:03:12 -0700 Subject: [PATCH 1/2] Adds initial unit tests. --- tests/unit/__init__.py | 0 tests/unit/test_api.py | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/test_api.py diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/test_api.py b/tests/unit/test_api.py new file mode 100644 index 000000000..2d759cb77 --- /dev/null +++ b/tests/unit/test_api.py @@ -0,0 +1,10 @@ +import mock +from mock import MagicMock +import droneapi +from droneapi.module.api import APIModule +from nose.tools import assert_equals + +def test_mode(): + api = APIModule(MagicMock()) + res = api.get_connection() + assert_equals(len(res.get_vehicles()), 1) From d66a867682f8d422e68da197ac0fabe6321e9a3d Mon Sep 17 00:00:00 2001 From: Tim Ryan Date: Tue, 21 Jul 2015 15:04:10 -0700 Subject: [PATCH 2/2] Adds unit tests to CI. --- .travis.yml | 3 ++- appveyor.yml | 3 ++- circle.yml | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2a26cfdcc..23d4ebca5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,12 @@ env: install: - 'a() { set -e; }' - "z() { E=$?; test $E -eq 0 && return 0; printf \"\\n\\033[1;31mThe command failed with exit code $?.\\033[0m\"; set -e; return $E; }" - - (a; sudo pip2 install nose psutil );z + - (a; sudo pip2 install nose psutil mock );z - '(a; sudo pip2 install git+https://github.com/3drobotics/dronekit-sitl-runner.git );z' script: - (a; sudo python setup.py install );z - (a; nosetests tests/web );z + - (a; nosetests tests/unit );z - (a; cd tests; python -um sitl );z git: depth: 10 diff --git a/appveyor.yml b/appveyor.yml index 9ab199445..cfb39922e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,11 +18,12 @@ install: '@ | out-file -Encoding ascii -FilePath c:\Users\appveyor\pip\pip.ini - cmd: 'setlocal & python -m pip install pip wheel -U & endlocal' - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 wheel numpy & endlocal" - - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 install nose numpy psutil & endlocal" + - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 install nose numpy psutil mock & endlocal" - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 install git+https://github.com/3drobotics/dronekit-sitl-runner.git & endlocal" build_script: - cmd: 'setlocal & python setup.py install & endlocal' - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & nosetests tests\\web & endlocal" + - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & nosetests tests\\unit & endlocal" - cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & cd tests & python -um sitl & endlocal" clone_depth: 10 test: 'off' diff --git a/circle.yml b/circle.yml index 5388316a0..72d066308 100644 --- a/circle.yml +++ b/circle.yml @@ -9,10 +9,12 @@ dependencies: environment: {} - nosetests tests/web: environment: {} + - nosetests tests/unit: + environment: {} - cd tests; python -um sitl: environment: {} pre: - - pip2 install nose psutil: + - pip2 install nose psutil mock: environment: {} - 'pip2 install git+https://github.com/3drobotics/dronekit-sitl-runner.git': environment: {}