def test_force_refresh_oauth_token_error(self, Command): Command.return_value = mock.Mock( stdout=io.BytesIO(b"error"), stderr=io.BytesIO(b""), returncode=1 ) config = ScratchOrgConfig({"username": "******"}, "test") with self.assertRaises(ScratchOrgException): config.force_refresh_oauth_token()
def test_force_refresh_oauth_token(self, Command): Command.return_value = p = mock.Mock( stdout=io.BytesIO(b""), stderr=io.BytesIO(b""), returncode=0 ) config = ScratchOrgConfig({"username": "******"}, "test") config.force_refresh_oauth_token() p.run.assert_called_once()
def test_force_refresh_oauth_token_error(self, Command): Command.return_value = p = mock.Mock( stdout=io.BytesIO(b'error'), stderr=io.BytesIO(b''), returncode=1, ) config = ScratchOrgConfig({'username': '******'}, 'test') with self.assertRaises(ScratchOrgException): config.force_refresh_oauth_token()
def test_force_refresh_oauth_token(self, Command): Command.return_value = p = mock.Mock( stdout=io.BytesIO(b''), stderr=io.BytesIO(b''), returncode=0, ) config = ScratchOrgConfig({'username': '******'}, 'test') config.force_refresh_oauth_token() p.run.assert_called_once()
def test_refresh_oauth_token(self, Command): result = b"""{ "result": { "instanceUrl": "url", "accessToken": "access!token", "username": "******", "password": "******", "createdDate": "1970-01-01T:00:00:00Z", "expirationDate": "1970-01-08" } }""" Command.return_value = mock.Mock(stdout=io.BytesIO(result), stderr=io.BytesIO(b""), returncode=0) config = ScratchOrgConfig({ "username": "******", "created": True }, "test") config._sfdx_info = {} config._sfdx_info_date = datetime.now() - timedelta(days=1) config.force_refresh_oauth_token = mock.Mock() config._load_orginfo = mock.Mock() config.refresh_oauth_token(keychain=None) config.force_refresh_oauth_token.assert_called_once() self.assertTrue(config._sfdx_info)
def test_refresh_oauth_token(self, Command): result = b'''{ "result": { "instanceUrl": "url", "accessToken": "access!token", "username": "******", "password": "******" } }''' Command.return_value = mock.Mock(stdout=io.BytesIO(result), stderr=io.BytesIO(b''), returncode=0) config = ScratchOrgConfig({'username': '******'}, 'test') config._scratch_info = {} config._scratch_info_date = datetime.now() - timedelta(days=1) config.force_refresh_oauth_token = mock.Mock() config.refresh_oauth_token(keychain=None) config.force_refresh_oauth_token.assert_called_once() self.assertTrue(config._scratch_info)
def test_refresh_oauth_token(self, Command): result = b"""{ "result": { "instanceUrl": "url", "accessToken": "access!token", "username": "******", "password": "******" } }""" Command.return_value = mock.Mock( stdout=io.BytesIO(result), stderr=io.BytesIO(b""), returncode=0 ) config = ScratchOrgConfig({"username": "******"}, "test") config._scratch_info = {} config._scratch_info_date = datetime.now() - timedelta(days=1) config.force_refresh_oauth_token = mock.Mock() config._load_orginfo = mock.Mock() config.refresh_oauth_token(keychain=None) config.force_refresh_oauth_token.assert_called_once() self.assertTrue(config._scratch_info)