Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 864f941

Browse files
committed
Merge pull request dronekit#223 from diydrones/tcr-unit
Adds unit tests as a class of test.
2 parents 2f61adc + d66a867 commit 864f941

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ env:
77
install:
88
- 'a() { set -e; }'
99
- "z() { E=$?; test $E -eq 0 && return 0; printf \"\\n\\033[1;31mThe command failed with exit code $?.\\033[0m\"; set -e; return $E; }"
10-
- (a; sudo pip2 install nose psutil );z
10+
- (a; sudo pip2 install nose psutil mock );z
1111
- '(a; sudo pip2 install git+https://github.com/3drobotics/dronekit-sitl-runner.git );z'
1212
script:
1313
- (a; sudo python setup.py install );z
1414
- (a; nosetests tests/web );z
15+
- (a; nosetests tests/unit );z
1516
- (a; cd tests; python -um sitl );z
1617
git:
1718
depth: 10

appveyor.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ install:
1818
'@ | out-file -Encoding ascii -FilePath c:\Users\appveyor\pip\pip.ini
1919
- cmd: 'setlocal & python -m pip install pip wheel -U & endlocal'
2020
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 wheel numpy & endlocal"
21-
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 install nose numpy psutil & endlocal"
21+
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 install nose numpy psutil mock & endlocal"
2222
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & pip2 install git+https://github.com/3drobotics/dronekit-sitl-runner.git & endlocal"
2323
build_script:
2424
- cmd: 'setlocal & python setup.py install & endlocal'
2525
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & nosetests tests\\web & endlocal"
26+
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & nosetests tests\\unit & endlocal"
2627
- cmd: "setlocal & SET PATH=%PYTHON%;c:\\Python27\\Scripts;%PATH% & cd tests & python -um sitl & endlocal"
2728
clone_depth: 10
2829
test: 'off'

circle.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ dependencies:
99
environment: {}
1010
- nosetests tests/web:
1111
environment: {}
12+
- nosetests tests/unit:
13+
environment: {}
1214
- cd tests; python -um sitl:
1315
environment: {}
1416
pre:
15-
- pip2 install nose psutil:
17+
- pip2 install nose psutil mock:
1618
environment: {}
1719
- 'pip2 install git+https://github.com/3drobotics/dronekit-sitl-runner.git':
1820
environment: {}

tests/unit/__init__.py

Whitespace-only changes.

tests/unit/test_api.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import mock
2+
from mock import MagicMock
3+
import droneapi
4+
from droneapi.module.api import APIModule
5+
from nose.tools import assert_equals
6+
7+
def test_mode():
8+
api = APIModule(MagicMock())
9+
res = api.get_connection()
10+
assert_equals(len(res.get_vehicles()), 1)

0 commit comments

Comments
 (0)