Changeset c386390 for .tests/btlib.py


Ignore:
Timestamp:
2021-03-29T13:01:22Z (4 years ago)
Author:
/ <>
Children:
b9b29f3
Parents:
cb80802
Message:

moar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • .tests/btlib.py

    rcb80802 rc386390  
    44import select
    55
     6FUN = [
     7"Did I ask you something?",
     8"Oh yeah, that's right.",
     9"Alright, alright. Now go back to work.",
     10"Buuuuuuuuuuuuuuuurp... Excuse me!",
     11"Yes?",
     12"No?",
     13]
     14
    615SEPARATOR = "="*60
    7 SMOLPARATOR = "-"*60
    816
    917class IrcClient:
     
    3846
    3947        if not connected:
    40             print("IRC connection failed for " + self.nick)
    41             sys.exit(1)
    42        
    43         print("IRC connection established for " + self.nick)
     48            return False
    4449
    4550        self.send_raw('USER ' + (self.nick + " ")*3)
    4651        self.send_raw('NICK ' + self.nick)
    4752        self.send_raw('JOIN &bitlbee')
     53        return True
    4854
    4955    def jabber_login(self):
     
    5359        time.sleep(1)
    5460        self.receive()
    55         if self.log.find('Logged in') == -1:
    56             print("Jabber login failed for " + self.nick)
    57             sys.exit(1)
    58         else:
    59             print("Jabber login successful for " + self.nick)
     61        return (self.log.find('Logged in') != -1):
    6062
    6163    def receive(self):
     
    9193    return received
    9294
    93 
    9495def perform_test(test_function):
    9596    clis = []
    9697    clis += [IrcClient('test1', 'asd')]
    9798    clis += [IrcClient('test2', 'asd')]
    98     for cli in clis:
    99         cli.connect()
    10099
    101100    fail = not test_function(clis)
     
    108107    print(SEPARATOR)
    109108   
    110 
    111109    if fail:
    112110        sys.exit(1)
    113111
     112def connect_test(clis):
     113    ret = True
     114    for cli in clis:
     115        ret = ret & cli.connect()
     116    return ret
    114117
    115118def yes_test(clis):
     
    125128    return ret
    126129
     130def jabber_login_test(clis):
     131    ret = True
     132    for cli in clis:
     133        ret = ret & cli.jabber_login()
     134    return ret
     135
    127136def add_buddy_test(clis):
    128137    clis[0].add_jabber_buddy(clis[1].nick)
Note: See TracChangeset for help on using the changeset viewer.