~juju/pyjuju/0.7

« back to all changes in this revision

Viewing changes to juju/providers/common/tests/test_utils.py

  • Committer: Kapil Thangavelu
  • Author(s): Kapil Thangavelu
  • Date: 2013-01-29 16:55:45 UTC
  • mfrom: (608.1.3 test-sans-stat)
  • Revision ID: kapil.foss@gmail.com-20130129165545-v2ot9behc3y5dyxl
Disable charm store stats when testing.

When JUJU_TESTING is set to a non empty string value.

- Disable charm stats when getting charm-info or downloading charms.

When JUJU_TESTING is set to 'fast'

- For test instance startup speed, diable apt update/upgrade, also
  propogates to provisioning agent.

R=gary.poster, teknico
CC=
https://codereview.appspot.com/7143043

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
 
108
108
        lines = output.split("\n")
109
109
        self.assertEqual(lines.pop(0), "#cloud-config")
110
 
        config = serializer.load("\n".join(lines))
 
110
        config = serializer.yaml_load("\n".join(lines))
111
111
        self.assertEqual(config["ssh_authorized_keys"], ["zebra"])
112
112
        self.assertTrue(config["apt_update"])
113
113
        self.assertTrue(config["apt_upgrade"])
115
115
        self.assertEqual(config["apt_sources"], formatted_repos)
116
116
        self.assertEqual(config["runcmd"], scripts)
117
117
        self.assertEqual(config["machine-data"]["magic"], [1, 2, 3])
 
118
 
 
119
    def test_format_cloud_init_when_testing(self):
 
120
        """When in testing mode for speed of startup disable update/upgrade.
 
121
        """
 
122
        self.change_environment(JUJU_TESTING="fast")
 
123
        packages = ["python-lxml"]
 
124
        scripts = ["wget http://lwn.net > /tmp/out"]
 
125
        repositories = ["ppa:juju/pkgs"]
 
126
        output = format_cloud_init(
 
127
            ["zebra"],
 
128
            packages=packages,
 
129
            scripts=scripts,
 
130
            repositories=repositories,
 
131
            data={"magic": [1, 2, 3]})
 
132
 
 
133
        lines = output.split("\n")
 
134
        self.assertEqual(lines.pop(0), "#cloud-config")
 
135
        config = serializer.yaml_load("\n".join(lines))
 
136
        self.assertFalse(config["apt_update"])
 
137
        self.assertFalse(config["apt_upgrade"])
 
138
 
 
139
        self.change_environment(JUJU_TESTING="yes")
 
140
        output = format_cloud_init(
 
141
            ["zebra"],
 
142
            packages=packages,
 
143
            scripts=scripts,
 
144
            repositories=repositories,
 
145
            data={"magic": [1, 2, 3]})
 
146
 
 
147
        lines = output.split("\n")
 
148
        config = serializer.yaml_load("\n".join(lines))
 
149
        self.assertTrue(config["apt_update"])
 
150
        self.assertTrue(config["apt_upgrade"])