Skip to content

Commit

Permalink
Add unit tests for xlsx exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
pieqq committed Apr 23, 2024
1 parent d5aace8 commit 427414a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions checkbox-ng/plainbox/impl/exporter/test_xlsx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This file is part of Checkbox.
#
# Copyright 2024 Canonical Ltd.
# Written by:
# Pierre Equoy <pierre.equoy@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.

from collections import OrderedDict
from unittest import TestCase
from unittest.mock import MagicMock, ANY

from plainbox.impl.exporter.xlsx import XLSXSessionStateExporter


class XLSXSessionStateExporterTests(TestCase):
def test_write_job(self):
self_mock = MagicMock()
# tree = {"Uncategorised": {"job1": {}}}
tree = {"job1": {}}
result_map = {
"job1": OrderedDict(
[
("summary", "job1"),
("category_id", "com.canonical.plainbox::uncategorised"),
("outcome", "pass"),
("plugin", "shell"),
("io_log", ""),
("comments", ""),
("command", 'echo "This is job1"'),
("certification_status", "non-blocker"),
]
),
"Uncategorised": {
"category_status": "pass",
"plugin": "local",
"summary": "Uncategorised",
},
}
XLSXSessionStateExporter._write_job(self_mock, tree, result_map, 2)
# self_mock.worksheet3.write.assert_called()
self_mock.worksheet3.write.assert_any_call(ANY, ANY, "", ANY)
# self_mock.worksheet3.write.assert_called_with(ANY, ANY, "", ANY)
# self.assertEqual(self_mock.worksheet3.write.call_count, 2)

0 comments on commit 427414a

Please sign in to comment.