~allanlesage/uci-engine/coverage-extractor-plus-nfss-juju-deployment

« back to all changes in this revision

Viewing changes to coverage-retriever/coverageretriever/tests/test_generate_and_put_artifact.py

  • Committer: Allan LeSage
  • Date: 2014-10-13 19:57:50 UTC
  • Revision ID: allan.lesage@canonical.com-20141013195750-80izwpveb1l8ltus
Start a generate_and_put_artifact separate test file; docstring cleanups.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Ubuntu CI Engine
 
2
# Copyright 2014 Canonical Ltd.
 
3
#
 
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.
 
7
#
 
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.
 
12
#
 
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/>.
 
15
 
 
16
import unittest
 
17
 
 
18
from ci_utils.testing.fixtures import FakeDataStore
 
19
 
 
20
from coverageretriever.run_worker import (
 
21
    generate_and_put_artifact,
 
22
)
 
23
 
 
24
 
 
25
class GenerateAndPutArtifactTestCase(unittest.TestCase):
 
26
 
 
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(
 
32
            fake_data_store,
 
33
            message="Have a nice day!",
 
34
        )
 
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'])
 
38
 
 
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(
 
44
            fake_data_store,
 
45
            name='coverage.xml',
 
46
            reference='fake-swift-link',
 
47
            artifact_type='RESULTS',
 
48
        )
 
49
        self.assertEqual('coverage.xml', artifact['name'])
 
50
        self.assertEqual('RESULTS', artifact['artifact_type'])
 
51
        self.assertEqual('fake-swift-link', artifact['reference'])
 
52
 
 
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(
 
58
            fake_data_store,
 
59
            message='not-none',
 
60
        )
 
61
        self.assertEqual('not-none', artifact['message'])