aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/skype/test.py
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-02-17 20:51:11 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-02-17 20:51:11 +0100
commit94d9511f4e834f6082c2eadf6d1d35a65d162155 (patch)
tree0d7fb0a53e71c88cdf18f6d0fd19ac9c0f60be7e /protocols/skype/test.py
parent130f7b85cf0d75da8dbb98df6d52595fe24c65c9 (diff)
skype tests: run all tests with a single skyped config
This makes them a bit faster, and there is no need to have separate skyped configs for each test ATM.
Diffstat (limited to 'protocols/skype/test.py')
-rwxr-xr-xprotocols/skype/test.py57
1 files changed, 29 insertions, 28 deletions
diff --git a/protocols/skype/test.py b/protocols/skype/test.py
index ab90c955..632ae124 100755
--- a/protocols/skype/test.py
+++ b/protocols/skype/test.py
@@ -8,14 +8,35 @@ import shutil
import os
import hashlib
+def openssl(args):
+ with open(os.devnull, "w") as devnull:
+ proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull)
+ for i in range(6):
+ proc.stdin.write("\n")
+ proc.stdin.close()
+ proc.communicate()
+def setupSkyped():
+ try:
+ shutil.rmtree("t/skyped")
+ except OSError:
+ pass
+ os.makedirs("t/skyped")
+ cwd = os.getcwd()
+ os.chdir("t/skyped")
+ try:
+ shutil.copyfile("../../skyped.cnf", "skyped.cnf")
+ openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem'])
+ with open("skyped.conf", "w") as sock:
+ sock.write("[skyped]\n")
+ sock.write("username = alice\n")
+ sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest())
+ sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd())
+ sock.write("key = %s/skyped.key.pem\n" % os.getcwd())
+ sock.write("port = 2727\n")
+ finally:
+ os.chdir(cwd)
+
class Test(unittest.TestCase):
- def openssl(self, args):
- with open(os.devnull, "w") as devnull:
- proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull)
- for i in range(6):
- proc.stdin.write("\n")
- proc.stdin.close()
- proc.communicate()
def mock(self, name):
with open("t/skyped.log", "w") as skyped_log,\
open("t/pexpect.log", "w") as pexpect_log:
@@ -58,27 +79,6 @@ class Test(unittest.TestCase):
pass
os.makedirs("t/bitlbee")
- try:
- shutil.rmtree("t/skyped")
- except OSError:
- pass
- os.makedirs("t/skyped")
- cwd = os.getcwd()
- os.chdir("t/skyped")
- try:
- shutil.copyfile("../../skyped.cnf", "skyped.cnf")
- self.openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem'])
- with open("skyped.conf", "w") as sock:
- sock.write("[skyped]\n")
- sock.write("username = alice\n")
- sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest())
- sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd())
- sock.write("key = %s/skyped.key.pem\n" % os.getcwd())
- sock.write("port = 2727\n")
- finally:
- os.chdir(cwd)
-
-
def testMsg(self):
self.mock("msg")
@@ -128,4 +128,5 @@ class Test(unittest.TestCase):
self.mock("set-mood-text")
if __name__ == '__main__':
+ setupSkyped()
unittest.main()