-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_pidgin.py
53 lines (46 loc) · 2.32 KB
/
test_pidgin.py
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
import os
import unittest
import mock
from chat_unifier.file_iterators import pidgin
class PidginFileIteratorTest(unittest.TestCase):
def setUp(self):
self.maxDiff = None
def test_picks_correct_log_files(self):
with mock.patch.object(os, 'walk') as mock_walk:
mock_walk.return_value = [
('/logs', ('aim',), ('README.txt',)),
('/logs/aim', ('LocalUser123',), ()),
('/log/aim/LocalUser123', ('RemoteUser345', 'RemoteUser456'),
()),
('/log/aim/LocalUser123/RemoteUser345', (),
('2007-02-24.020826-0500EST.html',
'2007-02-25.154550-0500EST.html')),
('/log/aim/LocalUser123/RemoteUser456', (),
('2006-11-19.195755-0500EST.html',
'2006-11-22.112333-0500EST.html')),
]
self.assertEqual([
'/log/aim/LocalUser123/RemoteUser345/2007-02-24.020826-0500EST.html',
'/log/aim/LocalUser123/RemoteUser345/2007-02-25.154550-0500EST.html',
'/log/aim/LocalUser123/RemoteUser456/2006-11-19.195755-0500EST.html',
'/log/aim/LocalUser123/RemoteUser456/2006-11-22.112333-0500EST.html',
], [f for f in pidgin.iterate_files('/logs')])
def test_ignores_irc_log_files(self):
with mock.patch.object(os, 'walk') as mock_walk:
mock_walk.return_value = [
('/logs', ('aim', 'irc'), ('README.txt',)),
('/logs/aim', ('LocalUser123',), ()),
('/log/aim/LocalUser123', ('RemoteUser345',), ()),
('/log/aim/LocalUser123/RemoteUser345', (),
('2007-02-24.020826-0500EST.html',
'2007-02-25.154550-0500EST.html')),
('/log/irc', ('localuser123@irc.freenode.net',), ()),
('/log/irc/localuser123@irc.freenode.net', ('#dummy.chat',),
()),
('/log/irc/localuser123@irc.freenode.net/#dummy.chat', (),
('2006-06-21.200806-0400EST.html',)),
]
self.assertEqual([
'/log/aim/LocalUser123/RemoteUser345/2007-02-24.020826-0500EST.html',
'/log/aim/LocalUser123/RemoteUser345/2007-02-25.154550-0500EST.html',
], [f for f in pidgin.iterate_files('/logs')])