~chad.smith/charms/precise/block-storage-broker/bsb-ec2-boto

« back to all changes in this revision

Viewing changes to hooks/test_util.py

  • Committer: Chad Smith
  • Date: 2014-08-19 07:44:17 UTC
  • Revision ID: chad.smith@canonical.com-20140819074417-azghq6gaw4pg2uk7
unit test for setup_boto_config writing valid defined EC2_BOTO_CONFIG_FILE

Show diffs side-by-side

added added

removed removed

Lines of Context:
952
952
            {"key": "ec2key", "secret": "ec2password",
953
953
             "endpoint": "https://ec2-region-1.com",
954
954
             "default_volume_size": 11})
 
955
        util.EC2_BOTO_CONFIG_FILE = self.makeFile()
955
956
        util.log = util.hookenv.log
956
957
        self.storage = StorageServiceUtil("ec2")
957
958
 
 
959
    def test_wb_setup_boto_config(self):
 
960
        """
 
961
        L{_setup_boto_config} writes C{EC2_BOTO_CONFIG_FILE} with the provided C{key} and C{secret}
 
962
        parameters.
 
963
        """
 
964
        key = "my_ec2_key"
 
965
        secret = "my_secret_access_key"
 
966
        expected = ["[Credentials]",
 
967
                    "aws_access_key_id = %s" % key,
 
968
                    "aws_secret_access_key = %s" % secret]
 
969
        self.storage._setup_boto_config(key=key, secret=secret)
 
970
        with open(util.EC2_BOTO_CONFIG_FILE) as boto_config:
 
971
            lines = boto_config.readlines()
 
972
        
 
973
 
958
974
    def test_load_environment_with_ec2_variables(self):
959
975
        """
960
976
        L{load_environment} will setup script environment variables for ec2