This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor get_ec2_userdata to return list
This makes it easier to override the userdata in other modules. This means that bootstrap salt can extend the userdata without having to decode the mime message and re-mime it afterwards.
- Loading branch information
mattmb
committed
Jul 23, 2015
1 parent
2038504
commit 08e434d
Showing
3 changed files
with
48 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import email | ||
|
||
import unittest | ||
|
||
from testfixtures import compare | ||
|
||
from bootstrap_cfn import mime_packer | ||
|
||
|
||
class TestMimePacker(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.parts = [] | ||
self.parts.append({ | ||
'content': 'MORESTRING', | ||
'mime_type': 'text/cloud-boothook' | ||
}) | ||
self.parts.append({ | ||
'content': 'SOMESTRING', | ||
'mime_type': 'text/cloud-config' | ||
}) | ||
|
||
def test_encode(self): | ||
ret = mime_packer.pack(self.parts) | ||
self.assertTrue('SOMESTRING' in ret) | ||
self.assertTrue('MORESTRING' in ret) | ||
|
||
def test_decode(self): | ||
ret = mime_packer.pack(self.parts) | ||
parts = [part for part in email.message_from_string(ret).walk()] | ||
compare( | ||
[part.get_content_type() for part in parts], | ||
["multipart/mixed", "text/cloud-boothook", "text/cloud-config"], | ||
prefix="mimeparts are in expected order") | ||
compare(parts[1].get_payload(), "MORESTRING") | ||
compare(parts[2].get_payload(), "SOMESTRING") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters