2
# Copyright 2014 Canonical Ltd.
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License version 3, as
6
# published by the Free Software Foundation.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY; without even the implied warranties of
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
# PURPOSE. See the GNU Affero General Public License for more details.
13
# You should have received a copy of the GNU Affero General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
from ci_utils.testing.fixtures import FakeDataStore
20
from coverageretriever.run_worker import (
21
generate_and_put_artifact,
25
class GenerateAndPutArtifactTestCase(unittest.TestCase):
27
def test_logging_defaults(self):
28
"""Generate and put (and return) a log artifact."""
29
fake_data_store = FakeDataStore('fake_ticket_id')
30
self.addCleanup(fake_data_store.delete)
31
artifact = generate_and_put_artifact(
33
message="Have a nice day!",
35
self.assertEqual("Have a nice day!", artifact['message'])
36
self.assertEqual('LOGS', artifact['artifact_type'])
37
self.assertEqual('coverage-retriever.output.log', artifact['name'])
39
def test_coverage_xml_result(self):
40
"""Generate and put a coverage.xml artifact."""
41
fake_data_store = FakeDataStore('fake_ticket_id')
42
self.addCleanup(fake_data_store.delete)
43
artifact = generate_and_put_artifact(
46
reference='fake-swift-link',
47
artifact_type='RESULTS',
49
self.assertEqual('coverage.xml', artifact['name'])
50
self.assertEqual('RESULTS', artifact['artifact_type'])
51
self.assertEqual('fake-swift-link', artifact['reference'])
53
def test_message_is_not_none(self):
54
"""If no message, then substitute our header message."""
55
fake_data_store = FakeDataStore('fake_ticket_id')
56
self.addCleanup(fake_data_store.delete)
57
artifact = generate_and_put_artifact(
61
self.assertEqual('not-none', artifact['message'])