Changeset 94d9511 for protocols


Ignore:
Timestamp:
2013-02-17T19:51:11Z (11 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
9754c2f
Parents:
130f7b8
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/skype/test.py

    r130f7b8 r94d9511  
    99import hashlib
    1010
     11def openssl(args):
     12        with open(os.devnull, "w") as devnull:
     13                proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull)
     14                for i in range(6):
     15                        proc.stdin.write("\n")
     16                proc.stdin.close()
     17                proc.communicate()
     18def setupSkyped():
     19        try:
     20                shutil.rmtree("t/skyped")
     21        except OSError:
     22                pass
     23        os.makedirs("t/skyped")
     24        cwd = os.getcwd()
     25        os.chdir("t/skyped")
     26        try:
     27                shutil.copyfile("../../skyped.cnf", "skyped.cnf")
     28                openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem'])
     29                with open("skyped.conf", "w") as sock:
     30                        sock.write("[skyped]\n")
     31                        sock.write("username = alice\n")
     32                        sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest())
     33                        sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd())
     34                        sock.write("key = %s/skyped.key.pem\n" % os.getcwd())
     35                        sock.write("port = 2727\n")
     36        finally:
     37                os.chdir(cwd)
     38
    1139class Test(unittest.TestCase):
    12         def openssl(self, args):
    13                 with open(os.devnull, "w") as devnull:
    14                         proc = subprocess.Popen(['openssl'] + args, stdin=subprocess.PIPE, stderr=devnull)
    15                         for i in range(6):
    16                                 proc.stdin.write("\n")
    17                         proc.stdin.close()
    18                         proc.communicate()
    1940        def mock(self, name):
    2041                with open("t/skyped.log", "w") as skyped_log,\
     
    5879                        pass
    5980                os.makedirs("t/bitlbee")
    60 
    61                 try:
    62                         shutil.rmtree("t/skyped")
    63                 except OSError:
    64                         pass
    65                 os.makedirs("t/skyped")
    66                 cwd = os.getcwd()
    67                 os.chdir("t/skyped")
    68                 try:
    69                         shutil.copyfile("../../skyped.cnf", "skyped.cnf")
    70                         self.openssl(['req', '-new', '-x509', '-days', '365', '-nodes', '-config', 'skyped.cnf', '-out', 'skyped.cert.pem', '-keyout', 'skyped.key.pem'])
    71                         with open("skyped.conf", "w") as sock:
    72                                 sock.write("[skyped]\n")
    73                                 sock.write("username = alice\n")
    74                                 sock.write("password = %s\n" % hashlib.sha1("foo").hexdigest())
    75                                 sock.write("cert = %s/skyped.cert.pem\n" % os.getcwd())
    76                                 sock.write("key = %s/skyped.key.pem\n" % os.getcwd())
    77                                 sock.write("port = 2727\n")
    78                 finally:
    79                         os.chdir(cwd)
    80 
    8181
    8282        def testMsg(self):
     
    129129
    130130if __name__ == '__main__':
     131        setupSkyped()
    131132        unittest.main()
Note: See TracChangeset for help on using the changeset viewer.