def test_does_nothing_when_in_script(self, patch): patch('h.features.subscribers.db') Feature = patch('h.features.subscribers.Feature') event = ApplicationCreated(DummyApp()) remove_old_flags(event) assert not Feature.remove_old_flags.called
def test_exists(self): # Create the directory expected_location = self.shared_dir / TRACKED_PUBS_DIR expected_location.mkdir() # test this doesn't error... event = ApplicationCreated(self.app) create_tracked_pubs_location(event) assert expected_location.exists()
def test_cleans_up_database_session_and_connection(self, patch): db = patch('h.features.subscribers.db') patch('h.features.subscribers.Feature') event = ApplicationCreated(DummyApp()) remove_old_flags(event) db.Session.return_value.close.assert_called_once_with() db.make_engine.return_value.dispose.assert_called_once_with()
def test_removes_flags(self, patch): db = patch('h.features.subscribers.db') Feature = patch('h.features.subscribers.Feature') event = ApplicationCreated(DummyApp()) remove_old_flags(event) Feature.remove_old_flags.assert_called_once_with( db.Session.return_value)
def make_asyncio_app(config): self = config self.set_request_factory(RequestFactory()) self.commit() app = Router(self) # Allow tools like "pshell development.ini" to find the 'last' # registry configured. global_registries.add(self.registry) # Push the registry onto the stack in case any code that depends on # the registry threadlocal APIs used in listeners subscribed to the # IApplicationCreated event. self.manager.push({'registry': self.registry, 'request': None}) try: self.registry.notify(ApplicationCreated(app)) finally: self.manager.pop() return app
def make_wsgi_app(self): """ Commits any pending configuration statements, sends a :class:`pyramid.events.ApplicationCreated` event to all listeners, adds this configuration's registry to :attr:`pyramid.config.global_registries`, and returns a :app:`Pyramid` WSGI application representing the committed configuration state.""" self.commit() app = Router(self.registry) # Allow tools like "pshell development.ini" to find the 'last' # registry configured. global_registries.add(self.registry) # Push the registry on to the stack in case any code that depends on # the registry threadlocal APIs used in listeners subscribed to the # IApplicationCreated event. self.manager.push({'registry': self.registry, 'request': None}) try: self.registry.notify(ApplicationCreated(app)) finally: self.manager.pop() return app
def test_object_implements(self): from pyramid.events import ApplicationCreated event = ApplicationCreated(object()) from pyramid.interfaces import IApplicationCreated from zope.interface.verify import verifyObject verifyObject(IApplicationCreated, event)
def test(self): event = ApplicationCreated(self.app) create_tracked_pubs_location(event) expected_location = self.shared_dir / TRACKED_PUBS_DIR assert expected_location.exists()