def test_ssl_should_be_boolean(self): Config(app_id=u'4', key=u'key', secret=u'secret', ssl=False) Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True) self.assertRaises( TypeError, lambda: Config(app_id=u'4', key=u'key', secret=u'secret', ssl=4))
def test_secret_should_be_text(self): self.assertRaises( TypeError, lambda: Config(app_id=u'4', key=u'key', secret=4, ssl=False)) self.assertRaises( TypeError, lambda: Config( app_id=u'4', key=u'key', secret=b'secret', ssl=False))
def test_host_behaviour(self): conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True) self.assertEqual(conf.host, u'api.pusherapp.com', u'default host should be correct') conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, cluster=u'eu') self.assertEqual(conf.host, u'api-eu.pusher.com', u'host should be overriden by cluster setting') conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, host=u'foo') self.assertEqual(conf.host, u'foo', u'host should be overriden by host setting') conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, cluster=u'eu', host=u'plah') self.assertEqual(conf.host, u'plah', u'host should be used in preference to cluster')
def test_port_should_be_number(self): Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, port=400) self.assertRaises( TypeError, lambda: Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, port=u'400'))
def test_port_behaviour(self): conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True) self.assertEqual(conf.port, 443, u'port should be 443 for ssl') conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=False) self.assertEqual(conf.port, 80, u'port should be 80 for non ssl') conf = Config(app_id=u'4', key=u'key', secret=u'secret', ssl=False, port=4000) self.assertEqual(conf.port, 4000, u'the port setting override the default')
def test_host_should_be_text(self): Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, host=u'foo') self.assertRaises( TypeError, lambda: Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, host=b'foo')) self.assertRaises( TypeError, lambda: Config( app_id=u'4', key=u'key', secret=u'secret', ssl=True, host=4))
def test_cluster_should_be_text(self): Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, cluster=u'eu') self.assertRaises( TypeError, lambda: Config(app_id=u'4', key=u'key', secret=u'secret', ssl=True, cluster=b'eu')) self.assertRaises( TypeError, lambda: Config( app_id=u'4', key=u'key', secret=u'secret', ssl=True, cluster=4) )
def test_ssl_should_be_required(self): self.assertRaises( TypeError, lambda: Config(app_id=u'4', key=u'key', secret=b'secret'))
def test_should_be_constructable(self): Config(app_id=u'4', key=u'key', secret=u'secret', ssl=False)