コード例 #1
0
ファイル: test_supybot.py プロジェクト: albertinisg/perceval
    def test_fetch(self):
        """Test if it parses a set of log files"""

        backend = Supybot('http://example.com/', self.tmp_path)
        messages = [m for m in backend.fetch()]

        expected = [('benpol', 'comment', '89b0d9fdbc3972aed183876f7f5ee2617542665c', 1350465381.0),
                    ('benpol', 'comment', '81b1fbe651b58d6a4ef6fff026658f87b7c393fc', 1350465389.0),
                    ('benpol', 'comment', 'bb72ef7fca57e89a7b46826cc0029713fbeba8d7', 1350465395.0),
                    ('MikeMcClurg', 'server', '6f873e788e289acca517a1c04eaa3e8557191f99', 1350465410.0),
                    ('Tv_', 'server', 'fe19251eb5068bb7a14892960574b565b100fb29', 1350465411.0),
                    ('benpol', 'comment', 'ec3206582c534cb725bc5153b5037089441735d3', 1350465447.0),
                    ('Tv_', 'comment', '06b6fe28cdb55247d03430e72986068fdb168723',  1350465528.0),
                    ('jamespage', 'comment', '42a71797a6bd75c01b4de9476006e73ed14c0340', 1350552630.0),
                    ('LarsFronius_', 'server', '839f98f69f4d5c22973abaf67bc2931682e9a79b', 1350552630.0),
                    ('bchrisman', 'server', '2e2ea19565203033622e005d8b5a004b4763d770', 1350552658.0),
                    ('scuttlemonkey', 'comment', 'b756d43392386c6ed0d329a45d2afcbc11a9afe0', 1350552785.0),
                    ('loicd', 'server', '5a4fc4c6bd5903ababaaa391b2a53ba1178ee75a', 1350584011.0),
                    ('sagelap1', 'server', 'c68e87799f13dc346d580cc56daec0189f232276', 1350584041.0)]

        self.assertEqual(len(messages), len(expected))

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['nick'], expected[x][0])
            self.assertEqual(message['data']['type'], expected[x][1])
            self.assertEqual(message['origin'], 'http://example.com/')
            self.assertEqual(message['uuid'], expected[x][2])
            self.assertEqual(message['updated_on'], expected[x][3])
            self.assertEqual(message['category'], 'message')
            self.assertEqual(message['tag'], 'http://example.com/')
コード例 #2
0
    def test_fetch(self):
        """Test if it parses a set of log files"""

        backend = Supybot('http://example.com/', self.tmp_path)
        messages = [m for m in backend.fetch()]

        expected = [('benpol', 'comment',
                     '89b0d9fdbc3972aed183876f7f5ee2617542665c', 1350465381.0),
                    ('benpol', 'comment',
                     '81b1fbe651b58d6a4ef6fff026658f87b7c393fc', 1350465389.0),
                    ('benpol', 'comment',
                     'bb72ef7fca57e89a7b46826cc0029713fbeba8d7', 1350465395.0),
                    ('MikeMcClurg', 'server',
                     '6f873e788e289acca517a1c04eaa3e8557191f99', 1350465410.0),
                    ('Tv_', 'server',
                     'fe19251eb5068bb7a14892960574b565b100fb29', 1350465411.0),
                    ('benpol', 'comment',
                     'ec3206582c534cb725bc5153b5037089441735d3', 1350465447.0),
                    ('Tv_', 'comment',
                     '06b6fe28cdb55247d03430e72986068fdb168723', 1350465528.0),
                    ('jamespage', 'comment',
                     '42a71797a6bd75c01b4de9476006e73ed14c0340', 1350552630.0),
                    ('LarsFronius_', 'server',
                     '839f98f69f4d5c22973abaf67bc2931682e9a79b', 1350552630.0),
                    ('bchrisman', 'server',
                     '2e2ea19565203033622e005d8b5a004b4763d770', 1350552658.0),
                    ('scuttlemonkey', 'comment',
                     'b756d43392386c6ed0d329a45d2afcbc11a9afe0', 1350552785.0),
                    ('loicd', 'server',
                     '5a4fc4c6bd5903ababaaa391b2a53ba1178ee75a', 1350584011.0),
                    ('sagelap1', 'server',
                     'c68e87799f13dc346d580cc56daec0189f232276', 1350584041.0)]

        self.assertEqual(len(messages), len(expected))

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['nick'], expected[x][0])
            self.assertEqual(message['data']['type'], expected[x][1])
            self.assertEqual(message['origin'], 'http://example.com/')
            self.assertEqual(message['uuid'], expected[x][2])
            self.assertEqual(message['updated_on'], expected[x][3])
            self.assertEqual(message['category'], 'message')
            self.assertEqual(message['tag'], 'http://example.com/')
コード例 #3
0
ファイル: test_supybot.py プロジェクト: acs/perceval
    def test_fetch_from_date(self):
        """Test whether a list of messages is returned since a given date"""

        from_date = datetime.datetime(2012, 10, 18, 9, 33, 5)

        backend = Supybot('http://example.com/', self.tmp_path)
        messages = [m for m in backend.fetch(from_date=from_date)]

        expected = [('scuttlemonkey', 'comment', 'b756d43392386c6ed0d329a45d2afcbc11a9afe0', 1350552785.0),
                    ('loicd', 'server', '5a4fc4c6bd5903ababaaa391b2a53ba1178ee75a', 1350584011.0),
                    ('sagelap1', 'server', 'c68e87799f13dc346d580cc56daec0189f232276', 1350584041.0)]

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['nick'], expected[x][0])
            self.assertEqual(message['data']['type'], expected[x][1])
            self.assertEqual(message['origin'], 'http://example.com/')
            self.assertEqual(message['uuid'], expected[x][2])
            self.assertEqual(message['updated_on'], expected[x][3])
コード例 #4
0
    def test_fetch_from_date(self):
        """Test whether a list of messages is returned since a given date"""

        from_date = datetime.datetime(2012, 10, 18, 9, 33, 5)

        backend = Supybot('http://example.com/', self.tmp_path)
        messages = [m for m in backend.fetch(from_date=from_date)]

        expected = [('scuttlemonkey', 'comment',
                     'b756d43392386c6ed0d329a45d2afcbc11a9afe0', 1350552785.0),
                    ('loicd', 'server',
                     '5a4fc4c6bd5903ababaaa391b2a53ba1178ee75a', 1350584011.0),
                    ('sagelap1', 'server',
                     'c68e87799f13dc346d580cc56daec0189f232276', 1350584041.0)]

        for x in range(len(messages)):
            message = messages[x]
            self.assertEqual(message['data']['nick'], expected[x][0])
            self.assertEqual(message['data']['type'], expected[x][1])
            self.assertEqual(message['origin'], 'http://example.com/')
            self.assertEqual(message['uuid'], expected[x][2])
            self.assertEqual(message['updated_on'], expected[x][3])