~nskaggs/juju-ci-tools/update-templates

« back to all changes in this revision

Viewing changes to template_test.py.tmpl

  • Committer: Nicholas Skaggs
  • Date: 2016-04-01 00:52:23 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20160401005223-xbj6hq3w5nhkk4i2
wip, fix unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
from assess_TEMPLATE import (
8
8
    assess_TEMPLATE,
 
9
    get_current_version,
 
10
    make_charm,
 
11
    main,
9
12
    parse_args,
10
 
    main,
11
13
)
12
14
from tests import (
13
15
    parse_error,
61
63
class TestAssess(TestCase):
62
64
 
63
65
    def test_TEMPLATE(self):
64
 
        mock_client = Mock(spec=["juju", "wait_for_started"])
65
 
        assess_TEMPLATE(mock_client)
66
 
        mock_client.juju.assert_called_once_with(
67
 
            'deploy', ('local:trusty/my-charm',))
68
 
        mock_client.wait_for_started.assert_called_once_with()
69
 
        self.assertNotIn("TODO", self.log_stream.getvalue())
 
66
                argv = ["an-env", "/bin/juju", "/tmp/logs", "an-env-mod", "--verbose"]
 
67
                args = parse_args(argv)
 
68
                mock_client = Mock(spec=["juju", "wait_for_started"])
 
69
                with patch("assess_TEMPLATE.get_current_version",
 
70
                   autospec=True, return_value="2.0.0") as mock_gcv:
 
71
                        with patch("assess_TEMPLATE.temp_dir",
 
72
                                           autospec=True) as mock_td:
 
73
                                with patch("assess_TEMPLATE.make_charm",
 
74
                                                   autospec=True) as mock_mc:
 
75
                                        assess_TEMPLATE(mock_client, args)
 
76
                mock_client.wait_for_started.assert_called_once_with()
 
77
                mock_gcv.assert_called_once_with(mock_client, '/bin/juju')
 
78
                temp_dir = mock_td.return_value.__enter__.return_value
 
79
        #self.assertNotIn("TODO", self.log_stream.getvalue())
70
80
 
71
81
    def test_make_charm(self):
72
82
        with temp_dir() as charm_dir: