def test_will_request_aws_creds_if_profile_doesnt_exist_save_to_file(self, fake_input, fake_exists, fake_profile_exists, fake_get_file_path, fake_load_from_tmpl): profile_name = '<profile_name>' key = '<key>' secret = '<secret>' fake_exists.expects_call().returns(False) fake_input.expects_call().returns('python') fake_input.next_call().returns('git') fake_input.next_call().returns(profile_name) fake_profile_exists.expects_call().with_args(profile_name).returns(False) fake_input.next_call().returns('y') fake_input.next_call().returns(key) fake_input.next_call().returns(secret) fake_get_file_path.expects_call().returns('my_creds') fake_load_from_tmpl.expects_call().returns({}) init(self.file_name) with(open('my_creds')) as fp: lines = fp.readlines() self.assertEqual(len(lines), 4) self.assertEqual(lines[0], '[{0}]\n'.format(profile_name)) self.assertEqual(lines[1], 'aws_access_key_id = {0}\n'.format(key)) self.assertEqual(lines[2], 'aws_secret_access_key = {0}\n'.format(secret)) os.remove('my_creds')
def test_will_skip_aws_creds_if_profile_exists(self, fake_input, fake_exists, FakeSession, fake_load_from_tmpl): profile_name = '<profile_name>' fake_exists.expects_call().returns(False) fake_input.expects_call().returns('python') fake_input.next_call().returns(profile_name) FakeSession.expects_call().with_args(profile_name).returns(True) fake_load_from_tmpl.expects_call().returns({}) init(self.file_name)
def test_will_request_aws_creds_if_profile_doesnt_exist(self, fake_input, fake_path_exists, profile_exists, profile_save, fake_load_tmpl): profile_name = '<profile_name>' key = '<key>' secret = '<secret>' fake_path_exists.expects_call().returns(False) fake_input.expects_call().returns('python') fake_input.next_call().returns(profile_name) profile_exists.expects_call().with_args(profile_name).returns(False) fake_input.next_call().returns('y') fake_input.next_call().returns(key) fake_input.next_call().returns(secret) fake_load_tmpl.expects_call().returns({}) profile_save.expects_call().with_args(profile_name, key, secret) init(self.file_name)