def test_api2_non_auth_credentials(self): """Test converting api 2 non auth credentials.""" with custom_qiskitrc(): store_credentials(Credentials('A', url=QE2_URL)) _ = update_credentials(force=True) # Assert over the stored (updated) credentials. loaded_accounts, _ = read_credentials_from_qiskitrc() self.assertCorrectApi2Credentials('A', loaded_accounts)
def test_qconsole_credentials(self): """Test converting Qconsole credentials.""" with custom_qiskitrc(): store_credentials(Credentials('A', url=IBMQ_TEMPLATE.format('a', 'b', 'c'))) _ = update_credentials(force=True) # Assert over the stored (updated) credentials. loaded_accounts, _ = read_credentials_from_qiskitrc() self.assertCorrectApi2Credentials('A', loaded_accounts)
def test_unknown_credentials(self): """Test converting credentials with an unknown URL.""" with custom_qiskitrc(): store_credentials(Credentials('A', url='UNKNOWN_URL')) credentials = update_credentials(force=True) # No credentials should be returned nor updated. self.assertIsNone(credentials) loaded_accounts, _ = read_credentials_from_qiskitrc() self.assertEqual(list(loaded_accounts.values())[0].url, 'UNKNOWN_URL')
def test_multiple_credentials(self): """Test converting multiple credentials.""" with custom_qiskitrc(): store_credentials(Credentials('A', url=QE2_AUTH_URL)) store_credentials(Credentials('B', url=IBMQ_TEMPLATE.format('a', 'b', 'c'))) store_credentials(Credentials('C', url=IBMQ_TEMPLATE.format('d', 'e', 'f'))) _ = update_credentials(force=True) # Assert over the stored (updated) credentials. loaded_accounts, _ = read_credentials_from_qiskitrc() # We don't assert over the token, as it depends on the order of # the qiskitrc, which is not guaranteed. self.assertCorrectApi2Credentials(None, loaded_accounts)
def test_proxy_credentials(self): """Test converting credentials with proxy values.""" with custom_qiskitrc(): store_credentials(Credentials('A', url=IBMQ_TEMPLATE.format('a', 'b', 'c'), proxies=PROXIES)) _ = update_credentials(force=True) # Assert over the stored (updated) credentials. loaded_accounts, _ = read_credentials_from_qiskitrc() self.assertCorrectApi2Credentials('A', loaded_accounts) # Extra assert on preserving proxies. credentials = list(loaded_accounts.values())[0] self.assertEqual(credentials.proxies, PROXIES)