def test_get_s3_access_no_secret_key(self): with NamedTemporaryFile() as temp_file: temp_file.write(dedent("""\ [default] access_key = fake_username """)) temp_file.flush() with self.assertRaisesRegexp( NoOptionError, "No option 'secret_key' in section: 'default'"): get_s3_credentials(temp_file.name)
def test_get_s3_access_no_secret_key(self): with NamedTemporaryFile() as temp_file: temp_file.write( dedent("""\ [default] access_key = fake_username """)) temp_file.flush() with self.assertRaisesRegexp( NoOptionError, "No option 'secret_key' in section: 'default'"): get_s3_credentials(temp_file.name)
def get_s3_access(): """ Return S3 access and secret keys """ s3cfg_path = os.path.join( os.getenv('HOME'), 'cloud-city/juju-qa.s3cfg') return get_s3_credentials(s3cfg_path)
def test_get_s3_credentials(self): with NamedTemporaryFile() as temp_file: temp_file.write(dedent("""\ [default] access_key = fake_username secret_key = fake_pass """)) temp_file.flush() access_key, secret_key = get_s3_credentials(temp_file.name) self.assertEqual(access_key, "fake_username") self.assertEqual(secret_key, "fake_pass")
def test_get_s3_credentials(self): with NamedTemporaryFile() as temp_file: temp_file.write( dedent("""\ [default] access_key = fake_username secret_key = fake_pass """)) temp_file.flush() access_key, secret_key = get_s3_credentials(temp_file.name) self.assertEqual(access_key, "fake_username") self.assertEqual(secret_key, "fake_pass")
def test_get_s3_credentials_missing(self): with self.assertRaises(IOError) as exc: get_s3_credentials('/asdf') self.assertEqual(exc.exception.errno, errno.ENOENT)
def get_s3_access(): """ Return S3 access and secret keys """ s3cfg_path = os.path.join(os.getenv('HOME'), 'cloud-city/juju-qa.s3cfg') return get_s3_credentials(s3cfg_path)