Exemple #1
0
 def test_remove_credentials(self):
     """Test removing credentials when preferences are set."""
     preferences = self._get_pref_dict()
     credentials = Credentials('QISKITRC_TOKEN', url=QE2_AUTH_URL)
     with custom_qiskitrc():
         store_credentials(credentials)
         store_preferences(preferences)
         configrc.remove_credentials(credentials)
         stored_cred, stored_pref = read_credentials_from_qiskitrc()
         self.assertEqual(preferences, stored_pref)
         self.assertFalse(stored_cred)
    def save(self):
        if self._credentials_changed:
            try:
                dict = read_credentials_from_qiskitrc()
                if dict is not None:
                    for credentials in dict.values():
                        remove_credentials(credentials)
            except:
                self._credentials = OrderedDict()

            for credentials in self._credentials.values():
                store_credentials(credentials, overwrite=True)

            self._credentials_changed = False