コード例 #1
0
ファイル: test_pkg.py プロジェクト: f3l/f3lbot
 def test_parse_aur_multi(self, testbot):
     # Multiple returns
     plugin = get_plugin(testbot, 'Pkg')
     input = plugin._Pkg__query_aur('pheerai', 'msearch')
     result = plugin._Pkg__parse_aur_multi(input)
     assert type(result) is list \
         and type(result[1]) is dict \
         and type(result[1]["name"]) is str
     # Single return
     plugin = get_plugin(testbot, 'Pkg')
     input = plugin._Pkg__query_aur('x32edit', 'info')
     result = plugin._Pkg__parse_aur_single(input["results"])
     assert type(result) is dict \
         and type(result["name"]) is str
コード例 #2
0
ファイル: test_pkg.py プロジェクト: f3l/f3lbot
    def test_print_packages(self, testbot):
        plugin = get_plugin(testbot, 'Pkg')
        # Single package
        expected = 'test1:\tJust testing'
        result = plugin._Pkg__print_packages(
            [
                {
                    'repo': 'test1',
                    'name': 'test1',
                    'desc': 'Just testing',
                }
            ]
        )
        assert expected == result
        # Multi packages
        expected = 'Foo!test1-test1:\tJust testing\ntest2-test2:\t\
Also just testing'
        result = plugin._Pkg__print_packages(
            [
                {
                    'repo': 'test1',
                    'name': 'test1',
                    'desc': 'Just testing',
                }, {
                    'repo': 'test2',
                    'name': 'test2',
                    'desc': 'Also just testing',
                }
            ],
            repo=True,
            sep="-",
            preamb="Foo!"
        )
        assert expected == result
コード例 #3
0
ファイル: test_pkg.py プロジェクト: f3l/f3lbot
 def test_query_arch(self, testbot):
     plugin = get_plugin(testbot, 'Pkg')
     result = plugin._Pkg__query_arch('name', '0ad')
     assert type(result) is dict \
         and result["valid"] is True \
         and type(result["results"]) is list \
         and type(result["results"][0]) is dict
コード例 #4
0
ファイル: test_pkg.py プロジェクト: f3l/f3lbot
 def test_parse_arch_multi(self, testbot):
     plugin = get_plugin(testbot, 'Pkg')
     result = plugin._Pkg__query_arch('name', '0ad')
     result2 = plugin._Pkg__parse_arch_multi(result["results"])
     assert type(result2) is list \
         and type(result2[0]) is dict \
         and type(result2[0]["name"]) is str
コード例 #5
0
ファイル: test_cite.py プロジェクト: f3l/f3lbot
 def test_get_random_cite(self, testbot):
         plugin = get_plugin(testbot, 'Cite')
         # 1st: get random (here: only) quote
         assert(plugin._Cite__random_cite() == "Foo")
         # 2nd: Empty DB
         self.db.zremrangebyrank(self.dbKey, 0, -1)
         assert(plugin._Cite__random_cite() == "No cites in DB")
コード例 #6
0
ファイル: test_cite.py プロジェクト: f3l/f3lbot
 def test_get_element(self, testbot):
         plugin = get_plugin(testbot, 'Cite')
         # 1st: index out of bounds
         assert(plugin._Cite__get_element(-1) == "Invalid index")
         assert(plugin._Cite__get_element(1) == "Invalid index")
         # 3rd: Index in bounds
         assert(plugin._Cite__get_element(0) == "Foo")
コード例 #7
0
ファイル: test_cite.py プロジェクト: f3l/f3lbot
 def test_dblen(self, testbot):
     plugin = get_plugin(testbot, 'Cite')
     assert(plugin.dblen == 0)
     self.db.zadd(self.dbKey,
                  1,
                  "Foo")
     assert(plugin.dblen == 1)
コード例 #8
0
ファイル: test_evil.py プロジェクト: f3l/f3lbot
 def test_legendary(self, testbot):
     # Has random, thus manually
     plugin = get_plugin(testbot, 'Evil')
     testbot.push_message("!legendary")
     result = testbot.pop_message()
     expected = plugin._Evil__legendaer
     assert result in expected
コード例 #9
0
ファイル: test_give.py プロジェクト: f3l/f3lbot
 def test_printto(self, testbot):
     plugin = get_plugin(testbot, "Give")
     expected = ["asdil1991", "asdil1991 and pheerai and asdil12"]
     result = [
         plugin._Give__printto(["asdil1991"], 1),
         plugin._Give__printto(["asdil1991", "and", "pheerai", "and", "asdil12"], 3),
     ]
     assert expected == result
コード例 #10
0
ファイル: test_give.py プロジェクト: f3l/f3lbot
 def test_evalto(self, testbot):
     plugin = get_plugin(testbot, "Give")
     expected = [1, 3]
     result = [
         plugin._Give__evalto(["asdil1991"]),
         plugin._Give__evalto(["asdil1991", "and", "pheerai", "and", "asdil12", "cool", "büchenbacher"]),
     ]
     assert result == expected
コード例 #11
0
ファイル: test_pkg.py プロジェクト: f3l/f3lbot
 def test_query_aur(self, testbot):
     plugin = get_plugin(testbot, 'Pkg')
     result = plugin._Pkg__query_aur('x32edit', 'info')
     assert type(result) is dict and type(result['results']) is dict
コード例 #12
0
ファイル: test_give.py プロジェクト: f3l/f3lbot
 def test_printargs(self, testbot):
     plugin = get_plugin(testbot, "Give")
     expected = [" ", " 1 2 3 "]
     result = [plugin._Give__printargs([]), plugin._Give__printargs(["1", "2", "3"])]
     assert result == expected