File: buffer_test.py

package info (click to toggle)
weechat-matrix 0.3.0-3.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 808 kB
  • sloc: python: 7,992; makefile: 27
file content (68 lines) | stat: -rw-r--r-- 2,681 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from matrix.buffer import WeechatChannelBuffer
from matrix.utils import parse_redact_args


class TestClass(object):
    def test_buffer(self):
        b = WeechatChannelBuffer("test_buffer_name", "example.org", "alice")
        assert b

    def test_buffer_print(self):
        b = WeechatChannelBuffer("test_buffer_name", "example.org", "alice")
        b.message("alice", "hello world", 0, 0)
        assert b

    def test_redact_args_parse(self):
        args = '$81wbnOYZllVZJcstsnXpq7dmugA775-JT4IB-uPT680|"Hello world" No specific reason'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$81wbnOYZllVZJcstsnXpq7dmugA775-JT4IB-uPT680'
        assert reason == 'No specific reason'

        args = '$15677776791893pZSXx:example.org|"Hello world" No reason at all'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$15677776791893pZSXx:example.org'
        assert reason == 'No reason at all'

        args = '$15677776791893pZSXx:example.org No reason at all'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$15677776791893pZSXx:example.org'
        assert reason == 'No reason at all'

        args = '$81wbnOYZllVZJcstsnXpq7dmugA775-JT4IB-uPT680 No specific reason'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$81wbnOYZllVZJcstsnXpq7dmugA775-JT4IB-uPT680'
        assert reason == 'No specific reason'

        args = '$81wbnOYZllVZJcstsnXpq7dmugA775-JT4IB-uPT680'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$81wbnOYZllVZJcstsnXpq7dmugA775-JT4IB-uPT680'
        assert reason == None

        args = '$15677776791893pZSXx:example.org'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$15677776791893pZSXx:example.org'
        assert reason == None

        args = '   '
        event_id, reason = parse_redact_args(args)
        assert event_id == ''
        assert reason == None

        args = '$15677776791893pZSXx:example.org|"Hello world"'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$15677776791893pZSXx:example.org'
        assert reason == None

        args = '$15677776791893pZSXx:example.org|"Hello world'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$15677776791893pZSXx:example.org'
        assert reason == None

        args = '$15677776791893pZSXx:example.org "Hello world"'
        event_id, reason = parse_redact_args(args)
        assert event_id == '$15677776791893pZSXx:example.org'
        assert reason == '"Hello world"'