python - Where does app get assigned? I keep getting BadArgumentError: app must not be empty -
i'm attempting build simple google app engine app using tdd.
$ python functional_tests.py
warning:root:initial generator _run_to_list(query.py:952) raised badargumenterror(app must not empty.) warning:root:suspended generator _get_async(query.py:1231) raised badargumenterror(app must not empty.) traceback (most recent call last): file "functional_tests.py", line 23, in <module> main import customer file "/users/bryan/work/googleappengine/dermalfillersecrets/main.py", line 39, in <module> if not ( client.query( client.name == "bryan wheelock").get()): file "/usr/local/google_appengine/google/appengine/ext/ndb/query.py", line 1218, in return self.get_async(**q_options).get_result() file "/usr/local/google_appengine/google/appengine/ext/ndb/tasklets.py", line 325, in get_result self.check_success() file "/usr/local/google_appengine/google/appengine/ext/ndb/tasklets.py", line 368, in _help_tasklet_along value = gen.throw(exc.__class__, exc, tb) file "/usr/local/google_appengine/google/appengine/ext/ndb/query.py", line 1231, in _get_async res = yield self.fetch_async(1, **q_options) file "/usr/local/google_appengine/google/appengine/ext/ndb/tasklets.py", line 371, in _help_tasklet_along value = gen.send(val) file "/usr/local/google_appengine/google/appengine/ext/ndb/query.py", line 957, in _run_to_list dsquery = self._get_query(conn) file "/usr/local/google_appengine/google/appengine/ext/ndb/query.py", line 918, in _get_query group_by=group_by) file "/usr/local/google_appengine/google/appengine/datastore/datastore_rpc.py", line 104, in positional_wrapper return wrapped(*args, **kwds) file "/usr/local/google_appengine/google/appengine/datastore/datastore_query.py", line 1906, in __init__ ancestor=ancestor) file "/usr/local/google_appengine/google/appengine/datastore/datastore_rpc.py", line 104, in positional_wrapper return wrapped(*args, **kwds) file "/usr/local/google_appengine/google/appengine/datastore/datastore_query.py", line 1745, in __init__ self.__app = datastore_types.resolveappid(app).encode('utf-8') file "/usr/local/google_appengine/google/appengine/api/datastore_types.py", line 229, in resolveappid validatestring(app, 'app', datastore_errors.badargumenterror) file "/usr/local/google_appengine/google/appengine/api/datastore_types.py", line 177, in validatestring raise exception('%s must not empty.' % name) google.appengine.api.datastore_errors.badargumenterror: app must not empty.
this code functional_test.py
from selenium import webdriver selenium.webdriver.common.keys import keys import unittest import sys sys.path.append("/usr/local/google_appengine") sys.path.append("/usr/local/google_appengine/lib/yaml/lib") sys.path.append("/usr/local/google_appengine/lib/webapp2-2.5.2") sys.path.append("/usr/local/google_appengine/lib/django-1.5") sys.path.append("/usr/local/google_appengine/lib/cherrypy") sys.path.append("/usr/local/google_appengine/lib/concurrent") sys.path.append("/usr/local/google_appengine/lib/docker") sys.path.append("/usr/local/google_appengine/lib/requests") sys.path.append("/usr/local/google_appengine/lib/websocket") sys.path.append("/usr/local/google_appengine/lib/fancy_urllib") sys.path.append("/usr/local/google_appengine/lib/antlr3") import dev_appserver google.appengine.tools.devappserver2 import devappserver2 google.appengine.tools.devappserver2 import python_runtime google.appengine.ext import testbed main import customer class newvisitortest(unittest.testcase): def setup(self): self.testbed = testbed.testbed() self.testbed.activate() self.testbed.init_datastore_v3_stub() # setup dev_appserver app_configs = ['app.yaml'] python_runtime._runtime_args = [ sys.executable, os.path.join(os.path.dirname(dev_appserver.__file__), '_python_runtime.py') ] options = devappserver2.parser.parse_args([ '--admin_port', '0', '--port', '9080', '--datastore_path', ':memory:', '--logs_path', ':memory:', '--skip_sdk_update_check', '--', ] + app_configs) server = devappserver2.developmentserver() server.start(options) self.server = server self.browser = webdriver.firefox() self.browser.implicitly_wait(3) def teardown(self): self.browser.quit() self.testbed.deactivate()
this code main.py:
import os import urllib import logging google.appengine.api import users google.appengine.ext import ndb import jinja2 import webapp2 jinja_environment = jinja2.environment( loader = jinja2.filesystemloader(os.path.dirname(__file__)), extensions=['jinja2.ext.autoescape'], autoescape=true) default_leadbook_name = 'namecustomer' # set parent key on 'customer' ensure in same # entity group. queries across single entity group consistent. # however, write rate should limited ~1/second. def leadbook_key(leadbook_name=default_leadbook_name): """constructs datastore key leadbook entity leadbook_name.""" return ndb.key('leadbook', leadbook_name) # client logs in user # take user.id , use create child client class client(ndb.model): # seems need figure out how have user log in via google add additional info email = ndb.stringproperty() # think email address name = ndb.stringproperty(indexed=true) street1 = ndb.stringproperty() street2 = ndb.stringproperty() city = ndb.stringproperty() zipcode = ndb.integerproperty() phone = ndb.stringproperty() signup = ndb.datetimeproperty(auto_now_add=true) if not ( client.query( client.name == "bryan wheelock").get()): logging.info("create admin") client = client( email = "bryan@mail.com", name = "bryan wheelock", street1 = "555 main st", street2 = "unit 1", city = "atlanta", zipcode = 99999, phone = "(888)555-1212" ).put()
i able resolve badargumenterror importing model setup of unittest.testcase .
class newvisitortest(unittest.testcase): def setup(self): self.testbed = testbed.testbed() self.testbed.activate() #self.testbed.setup_env(app_id='dermalfillersecrets') self.testbed.init_datastore_v3_stub() # setup dev_appserver app_configs = ['app.yaml'] python_runtime._runtime_args = [ sys.executable, os.path.join(os.path.dirname(dev_appserver.__file__), '_python_runtime.py') ] ######## moved import clause #### main import customer ######################################################### options = devappserver2.parser.parse_args([ '--admin_port', '0', '--port', '9080', '--datastore_path', ':memory:', '--logs_path', ':memory:', '--skip_sdk_update_check', '--', ] + app_configs) server = devappserver2.developmentserver() server.start(options) self.server = server self.browser = webdriver.firefox() self.browser.implicitly_wait(3)
Comments
Post a Comment