~smoser/cloud-init/azure_dhcp

« back to all changes in this revision

Viewing changes to tests/unittests/test_data.py

  • Committer: Scott Moser
  • Date: 2016-06-21 20:27:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1245.
  • Revision ID: smoser@ubuntu.com-20160621202702-q3khlzw7pc82ttec
user_data: fix error when user-data is not utf-8 decodable

when user-data was not decodable, cloud-init would raise exception.

Show diffs side-by-side

added added

removed removed

Lines of Context:
557
557
        ud_proc = ud.UserDataProcessor(self.getCloudPaths())
558
558
        message = ud_proc.process(msg)
559
559
        self.assertTrue(count_messages(message) == 1)
 
560
 
 
561
 
 
562
class TestConvert(helpers.TestCase):
 
563
    def test_handles_binary(self):
 
564
        blob = b'\x32\x99'
 
565
        msg = ud.convert_string(blob)
 
566
        self.assertEqual(blob, msg.get_payload(decode=True))
 
567
 
 
568
    def test_handle_headers(self):
 
569
        text = "hi mom"
 
570
        msg = ud.convert_string(text)
 
571
        self.assertEqual(text, msg.get_payload(decode=False))