def test_ExtendedConfType_to_string(): ct1 = ExtendedConfType() assert ct1.to_string() == b"00000000" ct2 = ExtendedConfType([1, 0, 1, 0, 1, 0, 1, 0]) assert ct2.to_string() == b"10101010" ct3 = ExtendedConfType([1, 1, 1, 1, 1, 1, 1, 1]) assert ct3.to_string() == b"11111111"
def test_ReqSetConfType(): conf_type = ConfType([1, 1, 1, 1]) r1 = requests.ReqSetConfType(14506, conf_type) assert r1.to_string() == b"21 14506 11110000\n" ext_conf_type = ExtendedConfType() r2 = requests.ReqSetConfType(14506, ext_conf_type) assert r2.to_string() == b"21 14506 00000000\n"
def test_ExtendedConfType_secret(): ct = ExtendedConfType([0, 0, 1, 0, 0, 0, 0, 0]) assert ct.rd_prot == 0 assert ct.original == 0 assert ct.secret == 1 assert ct.letterbox == 0 assert ct.allow_anonymous == 0 assert ct.forbid_secret == 0 assert ct.reserved2 == 0 assert ct.reserved3 == 0
def test_connection_try_to_reproduce_error(): s = MockSocket([ b'LysKOM\n', b'=1 8 38 33 20 15 4 112 2 135 0 9700 100 0 * 14506 38 33 20 15 4 112 2 135 0 00000000\n', b'=2 32HAndrokom - Komklient f\xf6r Android 00001000 921 13337\n' ]) c = Connection(s) sent_ref_no = c.send_request(ReqQueryReadTexts11(14506, 9700, 0, 0)) ref_no, resp, error = c.read_response() assert ref_no == sent_ref_no assert error is None expected = Membership11(position=8, last_time_read=Time(38, 33, 20, 15, 4, 112, 2, 135, 0), conference=9700, priority=100, added_by=14506, added_at=Time(38, 33, 20, 15, 4, 112, 2, 135, 0), membership_type=[0, 0, 0, 0, 0, 0, 0, 0]) #print "resp: ", repr(resp) #print "expected: ", repr(expected) assert resp == expected sent_ref_no = c.send_request(ReqGetUconfStat(14391)) ref_no, resp, error = c.read_response() assert ref_no == sent_ref_no assert error is None expected = UConference(name=b"Androkom - Komklient f\xf6r Android", conf_type=ExtendedConfType([0, 0, 0, 0, 1, 0, 0, 0]), highest_local_no=921, nice=13337) #print "resp: ", repr(resp) #print "expected: ", repr(expected) assert resp == expected assert s.recv_data == b""
def test_ExtendedConfType_default_constructor(): ct = ExtendedConfType() assert ct.to_string() == b"00000000"
def test_ExtendedConfType_length(): ct = ExtendedConfType() assert ExtendedConfType.LENGTH == 8 assert len(ct) == ExtendedConfType.LENGTH
def test_ExtendedConfType_constructor_can_convert_ConfType(): ct = ConfType([1, 1, 1, 1]) ect = ExtendedConfType(ct) assert ect.to_string() == b"11110000"