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
|
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
import models.base as modb
import models.boot as modbt
class TestBootModel(unittest.TestCase):
def test_boot_document_valid_instance(self):
boot_doc = modbt.BootDocument(
'board', 'job', 'kernel', 'defconfig', 'lab'
)
self.assertIsInstance(boot_doc, modb.BaseDocument)
def test_boot_document_to_dict(self):
self.maxDiff = None
boot_doc = modbt.BootDocument(
'board', 'job', 'kernel', 'defconfig', 'lab', arch='arm'
)
boot_doc.id = 'id'
boot_doc.job_id = 'job-id'
boot_doc.created_on = 'now'
boot_doc.defconfig_id = "defconfig_id"
boot_doc.retries = 10
boot_doc.version = "1.0"
boot_doc.dtb_append = False
boot_doc.boot_log = "boot-log"
boot_doc.boot_log_html = "boot-log-html"
boot_doc.warnings = 2
boot_doc.git_branch = "git-branch"
boot_doc.git_commit = "git-commit"
boot_doc.git_describe = "git-describe"
boot_doc.git_url = "git-url"
boot_doc.fastboot_cmd = "fastboot"
boot_doc.defconfig_full = "defconfig"
boot_doc.file_server_url = "file-server"
boot_doc.file_server_resource = "file-resource"
boot_doc.initrd = "initrd"
boot_doc.board_instance = "instance"
expected = {
'_id': 'id',
'board': 'board',
'boot_log': "boot-log",
'boot_log_html': "boot-log-html",
'boot_result_description': None,
'created_on': 'now',
'defconfig': 'defconfig',
'defconfig_id': "defconfig_id",
'dtb': None,
'dtb_addr': None,
'dtb_append': False,
'endian': None,
'fastboot': False,
'initrd_addr': None,
'job': 'job',
'job_id': 'job-id',
'kernel': 'kernel',
'kernel_image': None,
'lab_name': 'lab',
'load_addr': None,
'metadata': {},
'name': 'board-job-kernel-defconfig-arm',
'retries': 10,
'status': None,
'time': 0,
'version': "1.0",
'warnings': 2,
"git_commit": "git-commit",
"git_branch": "git-branch",
"git_describe": "git-describe",
"git_url": "git-url",
"arch": "arm",
"fastboot_cmd": "fastboot",
"defconfig_full": "defconfig",
"file_server_url": "file-server",
"file_server_resource": "file-resource",
"initrd": "initrd",
"board_instance": "instance"
}
self.assertDictEqual(expected, boot_doc.to_dict())
|