Skip to content

Commit de1a791

Browse files
author
Massimiliano Pippi
committed
added integration tests
1 parent 290217e commit de1a791

File tree

3 files changed

+74
-30
lines changed

3 files changed

+74
-30
lines changed

test/test_board.py

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
@pytest.mark.skipif(running_on_ci(), reason="VMs have no serial ports")
22-
def test_core_list(run_command):
22+
def test_board_list(run_command):
2323
result = run_command("core update-index")
2424
assert result.ok
2525
result = run_command("board list --format json")
@@ -33,37 +33,9 @@ def test_core_list(run_command):
3333

3434

3535
@pytest.mark.skipif(running_on_ci(), reason="VMs have no serial ports")
36-
def test_core_listall(run_command):
36+
def test_board_listall(run_command):
3737
assert run_command("core update-index")
3838
result = run_command("board listall")
3939
print(result.stderr, result.stdout)
4040
assert result.ok
4141
assert ["Board", "Name", "FQBN"] == result.stdout.splitlines()[0].strip().split()
42-
43-
44-
def test_core_search(run_command):
45-
url = "https://github.com/raw/arduino/arduino-cli/master/test/testdata/test_index.json"
46-
assert run_command("core update-index --additional-urls={}".format(url))
47-
# list all
48-
result = run_command("core search")
49-
assert result.ok
50-
assert 3 < len(result.stdout.splitlines())
51-
result = run_command("core search --format json")
52-
assert result.ok
53-
data = json.loads(result.stdout)
54-
assert 1 < len(data)
55-
# search a specific core
56-
result = run_command("core search avr")
57-
assert result.ok
58-
assert 2 < len(result.stdout.splitlines())
59-
result = run_command("core search avr --format json")
60-
assert result.ok
61-
data = json.loads(result.stdout)
62-
assert 0 < len(data)
63-
# additional URL
64-
result = run_command(
65-
"core search test_core --format json --additional-urls={}".format(url)
66-
)
67-
assert result.ok
68-
data = json.loads(result.stdout)
69-
assert 1 == len(data)

test/test_core.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# This file is part of arduino-cli.
2+
#
3+
# Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
4+
#
5+
# This software is released under the GNU General Public License version 3,
6+
# which covers the main part of arduino-cli.
7+
# The terms of this license can be found at:
8+
# https://www.gnu.org/licenses/gpl-3.0.en.html
9+
#
10+
# You can be released from the requirements of the above licenses by purchasing
11+
# a commercial license. Buying such a license is mandatory if you want to modify or
12+
# otherwise use the software for commercial activities involving the Arduino
13+
# software without disclosing the source code of your own applications. To purchase
14+
# a commercial license, send an email to [email protected].
15+
import pytest
16+
import simplejson as json
17+
18+
from .common import running_on_ci
19+
20+
21+
def test_core_search(run_command):
22+
url = "https://github.com/raw/arduino/arduino-cli/master/test/testdata/test_index.json"
23+
assert run_command("core update-index --additional-urls={}".format(url))
24+
# list all
25+
result = run_command("core search")
26+
assert result.ok
27+
assert 3 < len(result.stdout.splitlines())
28+
result = run_command("core search --format json")
29+
assert result.ok
30+
data = json.loads(result.stdout)
31+
assert 1 < len(data)
32+
# search a specific core
33+
result = run_command("core search avr")
34+
assert result.ok
35+
assert 2 < len(result.stdout.splitlines())
36+
result = run_command("core search avr --format json")
37+
assert result.ok
38+
data = json.loads(result.stdout)
39+
assert 0 < len(data)
40+
# additional URL
41+
result = run_command(
42+
"core search test_core --format json --additional-urls={}".format(url)
43+
)
44+
assert result.ok
45+
data = json.loads(result.stdout)
46+
assert 1 == len(data)
47+
# show all versions
48+
result = run_command(
49+
"core search test_core --all --format json --additional-urls={}".format(url)
50+
)
51+
assert result.ok
52+
data = json.loads(result.stdout)
53+
assert 2 == len(data)

test/testdata/test_index.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@
2525
"name": "Test Board"
2626
}
2727
]
28+
},
29+
{
30+
"category": "Test Category",
31+
"help": {
32+
"online": "https://github.com/Arduino/arduino-cli"
33+
},
34+
"url": "https://github.com/raw/arduino/arduino-cli/massi/additional-urls/test/testdata/core.txt",
35+
"checksum": "SHA-256:1ba93f6aea56842dfef065c0f5eb0a34c1f78b72b3f2426c94e47ba3a359c9ff",
36+
"name": "test_core",
37+
"version": "2.0.0",
38+
"architecture": "x86",
39+
"archiveFileName": "core.txt",
40+
"size": "2799",
41+
"toolsDependencies": [],
42+
"boards": [
43+
{
44+
"name": "Test Board"
45+
}
46+
]
2847
}
2948
],
3049
"tools": [],

0 commit comments

Comments
 (0)