From 5f0dc6840701a352eb7229cbc24aa050b7503af4 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Sun, 27 Dec 2015 16:31:00 +0100 Subject: [PATCH] Tests for twitter --- backends/twitter/TwitterPlugin.cpp | 7 +-- libtransport/Config.cpp | 1 + tests/start.py | 19 +++++-- tests/twitter/twitter.sql | Bin 0 -> 14336 bytes tests/twitter/twitter_test.cfg | 47 ++++++++++++++++++ tests/twitter/twitter_test.py | 77 +++++++++++++++++++++++++++++ 6 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 tests/twitter/twitter.sql create mode 100644 tests/twitter/twitter_test.cfg create mode 100644 tests/twitter/twitter_test.py diff --git a/backends/twitter/TwitterPlugin.cpp b/backends/twitter/TwitterPlugin.cpp index a91d288e..573323e8 100644 --- a/backends/twitter/TwitterPlugin.cpp +++ b/backends/twitter/TwitterPlugin.cpp @@ -75,9 +75,10 @@ TwitterPlugin::TwitterPlugin(Config *config, Swift::SimpleEventLoop *loop, Stora m_conn->connect(Swift::HostAddressPort(Swift::HostAddress(host), port)); tp = new ThreadPool(loop_, 10); - - tweet_timer = m_factories->getTimerFactory()->createTimer(90000); - message_timer = m_factories->getTimerFactory()->createTimer(90000); + + LOG4CXX_INFO(logger, "Fetch timeout is set to " << CONFIG_INT_DEFAULTED(config, "twitter.fetch_timeout", 90000)); + tweet_timer = m_factories->getTimerFactory()->createTimer(CONFIG_INT_DEFAULTED(config, "twitter.fetch_timeout", 90000)); + message_timer = m_factories->getTimerFactory()->createTimer(CONFIG_INT_DEFAULTED(config, "twitter.fetch_timeout", 90000)); tweet_timer->onTick.connect(boost::bind(&TwitterPlugin::pollForTweets, this)); message_timer->onTick.connect(boost::bind(&TwitterPlugin::pollForDirectMessages, this)); diff --git a/libtransport/Config.cpp b/libtransport/Config.cpp index ee513e0c..0208ce87 100644 --- a/libtransport/Config.cpp +++ b/libtransport/Config.cpp @@ -141,6 +141,7 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description ("proxy.user", value()->default_value(""), "Proxy user.") ("proxy.password", value()->default_value(""), "Proxy Password.") ("proxy.port", value()->default_value(0), "Proxy port.") + ("twitter.fetch_timeout", value()->default_value(0), "Proxy port.") ; diff --git a/tests/start.py b/tests/start.py index ca15b5e4..c4625a61 100644 --- a/tests/start.py +++ b/tests/start.py @@ -167,23 +167,36 @@ class JabberSlackServerModeConf(BaseTest): if test.find("bad_password") != -1: print "Changing password to 'badpassword'" os.system("sqlite3 slack.sql \"UPDATE users SET password='badpassword' WHERE id=1\"") - #os.system("sqlite3 slack.sql \"SELECT * FROM users\"") return False def pre_test(self): os.system("prosody --config ../slack_jabber/prosody.cfg.lua > prosody.log &") - #time.sleep(3) - #os.system("../../../spectrum_manager/src/spectrum2_manager -c manager.conf localhostxmpp set_oauth2_code xoxb-17213576196-VV2K8kEwwrJhJFfs5YWv6La6 use_bot_token 2>/dev/null >/dev/null") def post_test(self): os.system("killall lua-5.1 2>/dev/null") os.system("killall spectrum2_libpurple_backend 2>/dev/null") +class TwitterServerModeConf(BaseTest): + def __init__(self): + BaseTest.__init__(self, "../twitter/twitter_test.cfg", True, "") + self.directory = "../twitter/" + self.client_password = "testpass123" + + def skip_test(self, test): + os.system("cp ../twitter/twitter.sql .") + + def pre_test(self): + pass + + def post_test(self): + os.system("killall spectrum2_twitter_backend 2>/dev/null") + configurations = [] configurations.append(LibcommuniServerModeSingleServerConf()) configurations.append(LibcommuniServerModeConf()) configurations.append(JabberServerModeConf()) configurations.append(JabberSlackServerModeConf()) +configurations.append(TwitterServerModeConf()) exitcode = 0 diff --git a/tests/twitter/twitter.sql b/tests/twitter/twitter.sql new file mode 100644 index 0000000000000000000000000000000000000000..840aa0167c882aeef66bc3af233b28945a70175d GIT binary patch literal 14336 zcmeI3-*4MQ9Kd}(JBia~V;dzKMXIMhw9%H%j`Opd#?md_+V#i!Yoia7<-~5|HnCIN z>5sunH}MxBAx*r%0}|s2w5Mqj@B)Y@#Ka3c@GuZe0$xC34?~PQCw1a38A#Knsi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