~smoser/ubuntu/vivid/cloud-init/snappy

« back to all changes in this revision

Viewing changes to tests/unittests/test_handler/test_handler_seed_random.py

  • Committer: Scott Moser
  • Date: 2015-02-27 20:55:58 UTC
  • mfrom: (355.2.8 vivid)
  • Revision ID: smoser@ubuntu.com-20150227205558-glrwdgxqkaz6zyxa
* Merge with vivid at 0.7.7~bzr1067-0ubuntu1
* New upstream snapshot.
  * fix broken consumption of gzipped user-data (LP: #1424900)
  * functional user-data on Azure again (LP: #1423972)
  * CloudStack: support fetching password from virtual router (LP: #1422388)
* New upstream snapshot.
  * Fix for ascii decode in DataSourceAzure (LP: #1422993).
* New upstream snapshot.
  * support for gpt partitioning, utilized in Azure [Daniel Watkins]
  * fix bug in exception handling in mount_cb.
* New upstream snapshot.
  * move to python3 (LP: #1247132)
  * systemd: run cloud-init before systemd-user-sessions.service
  * Use the GCE short hostname. (LP: #1383794)
  * Enable user-data encoding support for GCE. (LP: #1404311)
  * Update to use a newer and better OMNIBUS_URL
  * Be more tolerant of 'ssh_authorized_keys' types
  * Fix parse_ssh_config failing in ssh_util.py
  * Increase the robustness/configurability of the chef module.
  * retain trailing newline from template files when using
    jinja2 (LP: #1355343)
  * fix broken output handling (LP: #1387340)
  * digital ocean datasource
  * update url in config drive documentation
  * freebsd: enable correct behavior on Ec2.
  * freebsd: Use the proper virtio FreeBSD network interface name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from cloudinit.config import cc_seed_random
20
20
 
21
 
import base64
22
21
import gzip
23
22
import tempfile
24
23
 
25
 
from StringIO import StringIO
 
24
from six import BytesIO
26
25
 
27
26
from cloudinit import cloud
28
27
from cloudinit import distros
69
68
        return
70
69
 
71
70
    def _compress(self, text):
72
 
        contents = StringIO()
 
71
        contents = BytesIO()
73
72
        gz_fh = gzip.GzipFile(mode='wb', fileobj=contents)
74
73
        gz_fh.write(text)
75
74
        gz_fh.close()
96
95
        self.assertEquals("tiny-tim-was-here", contents)
97
96
 
98
97
    def test_append_random_unknown_encoding(self):
99
 
        data = self._compress("tiny-toe")
 
98
        data = self._compress(b"tiny-toe")
100
99
        cfg = {
101
100
            'random_seed': {
102
101
                'file': self._seed_file,
108
107
                          self._get_cloud('ubuntu'), LOG, [])
109
108
 
110
109
    def test_append_random_gzip(self):
111
 
        data = self._compress("tiny-toe")
 
110
        data = self._compress(b"tiny-toe")
112
111
        cfg = {
113
112
            'random_seed': {
114
113
                'file': self._seed_file,
121
120
        self.assertEquals("tiny-toe", contents)
122
121
 
123
122
    def test_append_random_gz(self):
124
 
        data = self._compress("big-toe")
 
123
        data = self._compress(b"big-toe")
125
124
        cfg = {
126
125
            'random_seed': {
127
126
                'file': self._seed_file,
134
133
        self.assertEquals("big-toe", contents)
135
134
 
136
135
    def test_append_random_base64(self):
137
 
        data = base64.b64encode('bubbles')
 
136
        data = util.b64e('bubbles')
138
137
        cfg = {
139
138
            'random_seed': {
140
139
                'file': self._seed_file,
147
146
        self.assertEquals("bubbles", contents)
148
147
 
149
148
    def test_append_random_b64(self):
150
 
        data = base64.b64encode('kit-kat')
 
149
        data = util.b64e('kit-kat')
151
150
        cfg = {
152
151
            'random_seed': {
153
152
                'file': self._seed_file,