def test_exception_not_found_tag(self, tmpdir): p = tmpdir.join("credential") tmpdir.chdir() profiles = '' p.write(profiles) with pytest.raises(exception.NotFoundTag): credential.load(os.path.join(os.getcwd(), 'credential'))
def test_exception_default_tag_found(self, tmpdir): p = tmpdir.join("credential") tmpdir.chdir() profiles = '''[test] aws_access_key_id=AKIAIOSFODNN7EXAMPLE aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY [default] aws_access_key_id=DKIAIOSFODNN7EXAMPLG aws_secret_access_key=dJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY ''' p.write(profiles) tmpdir.chdir() with pytest.raises(exception.FoundDefault): credential.load(os.path.join(os.getcwd(), 'credential'))
def _set_default_credential(): crd.copy() profiles = crd.load(crd.DEFAULT_TEMPLATE_PATH) show_config() tag = _select_credentials(profiles) crd.set_default(tag) config.set_setting(tag, '') show_config()
def test_return_list_if_crednetial_file_is_correct(self, tmpdir): p = tmpdir.join(".credential") tmpdir.chdir() profiles = ''' [test] aws_access_key_id=AKIAIOSFODNN7EXAMPLE aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY [hoge] aws_access_key_id=DKIAIOSFODNN7EXAMPLG aws_secret_access_key=dJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY ''' p.write(profiles) tmpdir.chdir() assert credential.load(os.path.join( os.getcwd(), '.credential')) == ['test', 'hoge']
def test_exception_if_credential_file_does_not_exist(self, tmpdir): tmpdir.mkdir("sub") tmpdir.chdir() with pytest.raises(exception.NotFoundFile): credential.load(os.path.join(os.getcwd(), '.credential'))