def makeService(settings): service_collection = service.MultiService() cardstories_service = CardstoriesService(settings) plugins = CardstoriesPlugins(settings) plugins.load(cardstories_service) cardstories_service.setServiceParent(service_collection) site = CardstoriesSite(CardstoriesTree(cardstories_service), settings, plugins.plugins) if settings.get('manhole', None): internet.TCPServer( 2222, getManholeFactory(locals(), user="******"), interface='127.0.0.1').setServiceParent(service_collection) internet.TCPServer(settings['port'], site, interface=settings.get( 'interface', '127.0.0.1')).setServiceParent(service_collection) # if settings.has_key('ssl-port') and settings['ssl-port']: # internet.SSLServer(settings['ssl-port'], site, SSLContextFactory(settings) # ).setServiceParent(service_collection) return service_collection
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({'db': self.database}) self.service.startService() self.db = sqlite3.connect(self.database)
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({'db': self.database}) self.service.startService() self.db = sqlite3.connect(self.database) # Fake out the django table in our test db. c = self.db.cursor() c.execute("CREATE TABLE auth_user ( " " id INTEGER PRIMARY KEY, " " username VARCHAR(255), " " first_name VARCHAR(255) " "); ") c.execute( "CREATE TABLE cardstories_userprofile ( " " user_id INTEGER UNIQUE, " " activity_notifications_disabled BOOL NOT NULL DEFAULT False " "); ") c.close() # Mock out send.smtp_open() and # smtp.close() calls. class FakeSmtp(object): def close(self): pass def fake_smtp_open(): return FakeSmtp() send.smtp_open = fake_smtp_open
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({'db': self.database, 'plugins-confdir': 'CONFDIR', 'plugins-libdir': 'LIBDIR', 'static': 'STATIC' })
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({ 'db': self.database, 'plugins-libdir': '../fixture', 'plugins-confdir': '../fixture', 'plugins-dir': '../fixture' }) self.service.startService()
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({ 'db': self.database, 'plugins-confdir': '../fixture', 'plugins-libdir': 'LIBDIR', 'static': 'STATIC' }) self.service.auth = Mock() self.service.startService()
def test02_get_several_at_once(self): '''Generic methods to retreive several objects at once''' service = CardstoriesService({}) def check_call_for_each(method_name_multiple, method_name_single): mock = Mock(return_value=0) setattr(service.auth, method_name_single, mock) method = getattr(service.auth, method_name_multiple) method(["1", "2", "3", "4"]) self.assertEquals(mock.call_count, 4) check_call_for_each("get_players_ids", "get_player_id") check_call_for_each("get_players_names", "get_player_name") check_call_for_each("get_players_emails", "get_player_email") check_call_for_each("get_players_avatars_urls", "get_player_avatar_url")
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({'db': self.database, 'plugins-confdir': 'CONFDIR', 'plugins-libdir': 'LIBDIR', 'static': 'STATIC' }) self.service.startService() # Don't actually make delayed calls, but allow tests to call them self.default_reactor = activity.reactor.callLater self.activity_reactor = FakeReactor() activity.reactor = self.activity_reactor self.activity_instance = activity.Plugin(self.service, [])
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) # Empty 'chat/' subdir self.test_logdir = 'test_logdir.tmp' if os.path.exists(self.test_logdir): shutil.rmtree(self.test_logdir) self.service = CardstoriesService({ 'db': self.database, 'plugins-confdir': 'CONFDIR', 'plugins-libdir': 'LIBDIR', 'plugins-logdir': self.test_logdir, 'static': 'STATIC' }) self.service.startService()
def test01_exception_if_no_auth_plugin(self): '''If auth no plugin is loaded, auth methods should raise NotImplemented''' service = CardstoriesService({}) def check_not_implemented_method(method_name, *args, **kwargs): called = False try: method = getattr(service.auth, method_name) method(*args, **kwargs) except NotImplementedError: called = True self.assertEquals(called, True) check_not_implemented_method("authenticate", "request", "player_id") check_not_implemented_method("get_player_id", "email", create=True) check_not_implemented_method("get_player_name", "id") check_not_implemented_method("get_player_email", "id") check_not_implemented_method("get_player_avatar_url", "id")
def setUp(self): self.database = 'test.sqlite' if os.path.exists(self.database): os.unlink(self.database) self.service = CardstoriesService({'db': self.database, 'plugins-confdir': 'CONFDIR', 'plugins-libdir': 'LIBDIR', 'static': 'STATIC'}) self.service.auth = Mock() self.service.startService() # Fake an activity plugin to which the table plugin should listen self.mock_activity_instance = Mock() self.mock_activity_instance.name.return_value = 'activity' # Show all players as online self.mock_activity_instance.is_player_online.return_value = True self.table_instance = table.Plugin(self.service, [self.mock_activity_instance]) self.mock_activity_instance.listen.assert_called_once_with() self.mock_activity_instance.reset_mock()