-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathtest_board.py
106 lines (96 loc) · 4.28 KB
/
test_board.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# Copyright (c) 2020-2021 Arm Limited and Contributors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
"""Tests for `mbed_tools.targets.mbed_target`."""
from unittest import TestCase
# Import from top level as this is the expected interface for users
from mbed_tools.targets import Board
class TestBoard(TestCase):
"""Tests for the class `Board`."""
def test_offline_database_entry(self):
"""Given an entry from the offline database, a Board is generated with the correct information."""
board = Board.from_offline_board_entry(
{
"mbed_os_support": ["Mbed OS 5.15"],
"mbed_enabled": ["Basic"],
"board_type": "B_1",
"board_name": "Board 1",
"product_code": "P1",
"target_type": "platform",
"slug": "Le Slug",
}
)
self.assertEqual("B_1", board.board_type)
self.assertEqual("Board 1", board.board_name)
self.assertEqual(("Mbed OS 5.15",), board.mbed_os_support)
self.assertEqual(("Basic",), board.mbed_enabled)
self.assertEqual("P1", board.product_code)
self.assertEqual("platform", board.target_type)
self.assertEqual("Le Slug", board.slug)
self.assertEqual((), board.build_variant)
def test_empty_database_entry(self):
"""Given no data, a Board is created with no information."""
board = Board.from_online_board_entry({})
self.assertEqual("", board.board_type)
self.assertEqual("", board.board_name)
self.assertEqual((), board.mbed_os_support)
self.assertEqual((), board.mbed_enabled)
self.assertEqual("", board.product_code)
self.assertEqual("", board.target_type)
self.assertEqual("", board.slug)
def test_online_database_entry(self):
online_data = {
"type": "target",
"id": "1",
"attributes": {
"features": {
"mbed_enabled": ["Advanced"],
"mbed_os_support": [
"Mbed OS 5.10",
"Mbed OS 5.11",
"Mbed OS 5.12",
"Mbed OS 5.13",
"Mbed OS 5.14",
"Mbed OS 5.15",
"Mbed OS 5.8",
"Mbed OS 5.9",
],
"antenna": ["Connector", "Onboard"],
"certification": [
"Anatel (Brazil)",
"AS/NZS (Australia and New Zealand)",
"CE (Europe)",
"FCC/CFR (USA)",
"IC RSS (Canada)",
"ICASA (South Africa)",
"KCC (South Korea)",
"MIC (Japan)",
"NCC (Taiwan)",
"RoHS (Europe)",
],
"communication": ["Bluetooth & BLE"],
"interface_firmware": ["DAPLink", "J-Link"],
"target_core": ["Cortex-M4"],
"mbed_studio_support": ["Build and run"],
},
"board_type": "k64f",
"flash_size": 512,
"name": "u-blox NINA-B1",
"product_code": "0455",
"ram_size": 64,
"target_type": "module",
"hidden": False,
"device_name": "nRF52832_xxAA",
"slug": "u-blox-nina-b1",
},
}
board = Board.from_online_board_entry(online_data)
self.assertEqual(online_data["attributes"]["board_type"].upper(), board.board_type)
self.assertEqual(online_data["attributes"]["name"], board.board_name)
self.assertEqual(tuple(online_data["attributes"]["features"]["mbed_os_support"]), board.mbed_os_support)
self.assertEqual(tuple(online_data["attributes"]["features"]["mbed_enabled"]), board.mbed_enabled)
self.assertEqual(online_data["attributes"]["product_code"], board.product_code)
self.assertEqual(online_data["attributes"]["target_type"], board.target_type)
self.assertEqual(online_data["attributes"]["slug"], board.slug)
self.assertEqual(tuple(), board.build_variant)