def test_get_auto_renew_access_token(self, mock_get_access_token):
        fix_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data/access_token.json')
        with open(fix_path) as fd:
            fix = json.load(fd)

        mock_get_access_token.return_value = fix
        config = {'client_id': 'AAAA', 'client_secret': 'BBBB', 'uri': 'localhost'}
        az = AuthZero(config)
        az.access_token = az.get_access_token()
        az.access_token_valid_until = 0
        az.access_token_auto_renew = True
        az._authorize(az.default_headers)
    def test_expired_access_token(self, mock_get_access_token):
        fix_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data/access_token.json')
        with open(fix_path) as fd:
            fix = json.load(fd)

        mock_get_access_token.return_value = fix
        config = {'client_id': 'AAAA', 'client_secret': 'BBBB', 'uri': 'localhost'}
        az = AuthZero(config)
        az.access_token = az.get_access_token()
        az.access_token_valid_until = 0
        az.access_token_auto_renew = False
        with self.assertRaises(Exception) as context:
            az._authorize(az.default_headers)
        assert("('InvalidAccessToken', 'The access token has expired')" == str(context.exception))