Commit 543eb176 authored by Per Cederqvist's avatar Per Cederqvist

First commit. Contains the first of many test cases.

parent 55c9b270
import string
class factory:
def __init__(self, bcc_trigg, bcc_visible, other_trigg, other_visible):
self.__bcc_trigg = bcc_trigg
self.__bcc_visible = bcc_trigg + bcc_visible
self.__other_trigg = bcc_trigg + other_trigg
self.__other_visible = bcc_trigg + other_trigg + other_visible
for n in bcc_visible:
if n not in self.__other_visible:
self.__other_visible.append(n)
def create(self, misc, conf, loc):
if misc == 15:
trigg = self.__bcc_trigg
visib = self.__bcc_visible
else:
trigg = self.__other_trigg
visib = self.__other_visible
return misc_group(misc, conf, loc, trigg, visib)
class misc_group:
def __init__(self, misc, conf, loc, trigg, visib):
self.__misc = misc
self.__conf = conf
self.__loc = loc
self.__trigg = trigg
self.__visib = visib
def miscs(self, viewer, rec_time = None, sent_by = None, sent_at = None):
if viewer not in self.__visib:
return []
res = ["%d %d" % (self.__misc, self.__conf),
"6 %d" % self.__loc]
if rec_time != None:
res.append("7 $any_time")
if sent_by != None:
res.append("8 %d" % sent_by)
if sent_at != None:
res.append("9 $any_time")
return res
def trigger(self, viewer):
return viewer in self.__trigg
# (creator, recipient): trigger-bcc, trigger-other, is-visible-for
obj = {
(6, 6): factory([6], [], [], [7, 8, 9]),
(6, 7): factory([7], [6], [], [8, 9]),
(6, 8): factory([8], [6], [], [7, 9]),
(6, 9): factory([9], [6], [], [7, 8]),
(6, 10): factory([7, 8], [6], [], [9]),
}
class loc_no_allocator:
def __init__(self):
self.__prev = {}
def alloc(self, conf):
res = self.__prev.get(conf, 0) + 1
self.__prev[conf] = res
return res
locno = loc_no_allocator()
def talk_to(person):
global active_person
if active_person != person:
print "talk_to client %d" % (person - 6)
active_person = person
active_person = None
class sequence_allocator:
def __init__(self, start):
self.curr = start
def next(self):
self.curr = self.curr + 1
return self.curr
ref = sequence_allocator(999)
tno = sequence_allocator(0)
def create(author, recipients):
misc = []
crea = []
for (m, r) in recipients:
misc.append(obj[(author, r)].create(m, r, locno.alloc(r)))
crea.append("%d %d" % (m, r))
talk_to(author)
cs = ref.next()
tx = tno.next()
print "send \"%d 86 [holl \"text %d\"] %d { %s } 0 { }\\n\"" % (
cs, tx, len(crea), string.join(crea, " "))
new_text(author, tx, misc)
talk_to(author)
print "simple_expect \"=%d %d\"" % (cs, tx)
return (tx, misc)
PERSONS = range(6, 10)
def new_text(author, txt, misc):
for viewer in PERSONS:
sent = 0
pattern = []
for m in misc:
if m.trigger(viewer):
sent = 1
pattern = pattern + m.miscs(viewer)
if sent:
talk_to(viewer)
print "simple_expect \":18 15 %d $any_time " \
"%d 0 %d 0 %d { %s } 0 \\\\\\*\"" % (
txt, author, len("text %d" % txt),
len(pattern), string.join(pattern, " "))
else:
talk_to(viewer)
print "send \"%d 35\\n\"" % ref.next()
print "simple_expect \"=%d $any_time\"" % ref.curr
def setup():
print "lyskomd_start"
for p in PERSONS:
print "client_start %d" % (p - 6)
talk_to(p)
print "send \"A3Hfoo\\n\""
print "simple_expect \"LysKOM\" \"connected %d\"" % p
print "send \"%d 80 4 { 14 15 16 17 }\\n\"" % ref.next()
print "simple_expect \"=%d\"" % ref.curr
print "send \"%d 89 [holl \"Person %d\"] [holl \"foo\"] " \
"00000000 0 { }\\n\"" % (ref.next(), p)
print "simple_expect \"=%d %d\"" % (ref.curr, p)
print "send \"%d 62 %d [holl \"foo\"] 0\\n\"" % (ref.next(), p)
print "simple_expect \"=%d\"" % ref.curr
for (creator, conf, conf_type) in [
(7, 10, "0000"),
(7, 11, "1000"),
(7, 12, "1010"),
(9, 13, "0000"),
(9, 14, "1000"),
(9, 15, "1010"),
]:
talk_to(creator)
print "send \"%d 88 [holl \"conf %d\"] %s 0 { }\\n\"" % (
ref.next(), conf, conf_type)
print "simple_expect \"=%d %d\"" % (ref.curr, conf)
talk_to(7)
for conf in [10, 11, 12]:
for reader in [7, 8]:
print "send \"%d 100 %d %d 100 3 00000000\\n\"" % (
ref.next(), conf, reader)
print "simple_expect \"=%d\"" % ref.curr
talk_to(9)
for conf in [13, 14, 15]:
for reader in [7, 8]:
print "send \"%d 100 %d %d 100 6 00000000\\n\"" % (
ref.next(), conf, reader)
print "simple_expect \"=%d\"" % ref.curr
talk_to(7)
print "send \"%d 15 7 7\\n\"" % ref.next()
print "simple_expect \"=%d\"" % ref.curr
def disco():
for p in PERSONS[:-1]:
talk_to(p)
print "send \"%d 55 0\\n\"" % ref.next()
print "simple_expect \"=%d\"" % ref.curr
print "client_death %d" % (p - 6)
talk_to(PERSONS[-1])
print "send \"%d 62 5 [holl \"gazonk\"] 1\\n\"" % ref.next()
print "simple_expect \"=%d\"" % ref.curr
print "send \"%d 42 255\\n\"" % ref.next()
print "simple_expect \"=%d\"" % ref.curr
print "send \"%d 44 0\\n\"" % ref.next()
print "simple_expect \"=%d\"" % ref.curr
print "client_death %d" % (PERSONS[-1] - 6)
print "lyskomd_death"
setup()
create(6, [(0, 6)])
disco()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment