def index(_handler, _resp, lang, signed_ticket_id): languages.setup_locale(lang) cmd = facade.validate_login_link(signed_ticket_id, _handler.redirect) try: cmd.execute() except CommandExecutionException: _resp.status_code = 400 values = {'errors': cmd.errors, 'site': None} if cmd.result: search = DestinationsSearch(LoginSite, cmd.result) search.execute() if search.result: values['site'] = search.result[0] return TemplateResponse(values, "login_error.html")
def test_destinations_search(self): origin = Node() destinations = [Node() for i in xrange(3)] ndb.put_multi([origin] + destinations) arcs = [Arc(origin=origin.key, destination=d.key) for d in destinations] ndb.put_multi(arcs) search = DestinationsSearch(Arc, origin) search.execute() expected_keys = [n.key for n in destinations] actual_keys = [n.key for n in search.result] self.assertItemsEqual(expected_keys, actual_keys) cache_keys = memcache.get(destinations_cache_key(Arc, origin)) self.assertItemsEqual(expected_keys, cache_keys) # Assert Arcs are removed from cache Arc(origin=origin.key, destination=destinations[0].key).put() self.assertIsNone(memcache.get(destinations_cache_key(Arc, origin)))
def neighbor(cls): DestinationsSearch.arc_class = cls # To do: removing this because can cause side effects search = DestinationsSearch(lg) search.execute() self.assertEqual(1, len(search.result), cls) return search.result[0]
def neighbor(cls): DestinationsSearch.arc_class = cls search = DestinationsSearch(login) search.execute() self.assertEqual(1, len(search.result), cls) return search.result[0]