def test_connect(self): # If we build a conn without a wctoken, it doesn't do the connect # though it does get a session token # then we can call connect with a wctoken and it'll do it then with mock.patch.object(HealthVaultConn, '_get_auth_token') as gat: with mock.patch.object(HealthVaultConn, '_get_record_id') as gri: gri.return_value = 1 c = HealthVaultConn(app_id="1", app_thumbprint="2", public_key=TEST_PUBLIC_KEY, private_key=TEST_PRIVATE_KEY, wctoken=None, server="6", shell_server="7") self.assertIsNone(c.wctoken) self.assertFalse(c.is_authorized()) gat.assert_any_call() self.assertFalse(gri.called) self.assertIsNotNone(c.auth_token) with mock.patch.object(HealthVaultConn, '_get_auth_token') as gat: with mock.patch.object(HealthVaultConn, '_get_record_id') as gri: gri.return_value = 8 c.connect(wctoken="5") self.assertEqual("5", c.wctoken) gri.assert_any_call() self.assertTrue(c.is_authorized())
def test_is_authorized(self): with mock.patch.object(HealthVaultConn, '_get_auth_token'): c = HealthVaultConn( app_id="1", app_thumbprint="2", public_key=TEST_PUBLIC_KEY, private_key=TEST_PRIVATE_KEY, wctoken=None, server="6", shell_server="7" ) self.assertFalse(c.is_authorized()) c.authorized = True self.assertTrue(c.is_authorized())
def test_is_authorized(self): with mock.patch.object(HealthVaultConn, '_get_auth_token'): c = HealthVaultConn(app_id="1", app_thumbprint="2", public_key=TEST_PUBLIC_KEY, private_key=TEST_PRIVATE_KEY, wctoken=None, server="6", shell_server="7") self.assertFalse(c.is_authorized()) c.authorized = True self.assertTrue(c.is_authorized())
def test_connect(self): # If we build a conn without a wctoken, it doesn't do the connect # though it does get a session token # then we can call connect with a wctoken and it'll do it then with mock.patch.object(HealthVaultConn, '_get_auth_token') as gat: with mock.patch.object(HealthVaultConn, '_get_record_id') as gri: gri.return_value = 1 c = HealthVaultConn( app_id="1", app_thumbprint="2", public_key=TEST_PUBLIC_KEY, private_key=TEST_PRIVATE_KEY, wctoken=None, server="6", shell_server="7" ) self.assertIsNone(c.wctoken) self.assertFalse(c.is_authorized()) gat.assert_any_call() self.assertFalse(gri.called) self.assertIsNotNone(c.auth_token) with mock.patch.object(HealthVaultConn, '_get_auth_token') as gat: with mock.patch.object(HealthVaultConn, '_get_record_id') as gri: gri.return_value = 8 c.connect(wctoken="5") self.assertEqual("5", c.wctoken) gri.assert_any_call() self.assertTrue(c.is_authorized())