示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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')
示例#4
0
    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)
示例#5
0
    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)