-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from zertrin/master
Modification of the parsing regular expressions to handle both hh:mm:ss and hh:mm timestamp format in IRC log files
- Loading branch information
Showing
2 changed files
with
50 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,46 +23,61 @@ def _get_FUT(self, *args, **kwargs): | |
return LogLine(*args, **kwargs) | ||
|
||
def test_normal(self): | ||
line = "02:16 <ciblout> je suis secretaire, c'est moi qui decide" | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, "normal") | ||
self.assertEqual(m.message, "je suis secretaire, c'est moi qui decide") | ||
self.assertEqual(m.user, 'ciblout') | ||
self.assertEqual(m.time, '02:16') | ||
self.assertEqual(str(m), line) | ||
lines = [("02:16 <ciblout> je suis secretaire, c'est moi qui decide", "normal", "je suis secretaire, c'est moi qui decide", 'ciblout', '02:16'), | ||
("02:16:45 <ciblout> je suis secretaire, c'est moi qui decide", "normal", "je suis secretaire, c'est moi qui decide", 'ciblout', '02:16:45')] | ||
for line, expected_type, expected_message, expected_nick, expected_time in lines: | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, expected_type) | ||
self.assertEqual(m.message, expected_message) | ||
self.assertEqual(m.user, expected_nick) | ||
self.assertEqual(m.time, expected_time) | ||
self.assertEqual(str(m), line) | ||
|
||
def test_normal_empty(self): | ||
m = self._get_FUT("02:16 <ciblout>") | ||
self.assertEqual(m.type, "normal") | ||
self.assertEqual(m.message, "") | ||
lines = ["02:16 <ciblout>", | ||
"02:16:45 <ciblout>"] | ||
for line in lines: | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, "normal") | ||
self.assertEqual(m.message, "") | ||
|
||
def test_me(self): | ||
line = "02:16 * ciblout dit encore des conneries" | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, "me") | ||
self.assertEqual(m.message, "dit encore des conneries") | ||
self.assertEqual(m.user, 'ciblout') | ||
self.assertEqual(m.time, '02:16') | ||
self.assertEqual(str(m), line) | ||
lines = [("02:16 * ciblout dit encore des conneries", "me", "dit encore des conneries", 'ciblout', '02:16'), | ||
("02:16:45 * ciblout dit encore des conneries", "me", "dit encore des conneries", 'ciblout', '02:16:45')] | ||
for line, expected_type, expected_message, expected_nick, expected_time in lines: | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, expected_type) | ||
self.assertEqual(m.message, expected_message) | ||
self.assertEqual(m.user, expected_nick) | ||
self.assertEqual(m.time, expected_time) | ||
self.assertEqual(str(m), line) | ||
|
||
def test_me_empty(self): | ||
m = self._get_FUT("02:16 * ciblout") | ||
self.assertEqual(m.type, "me") | ||
self.assertEqual(m.message, "") | ||
lines = ["02:16 * ciblout", | ||
"02:16:45 * ciblout"] | ||
for line in lines: | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, "me") | ||
self.assertEqual(m.message, "") | ||
|
||
def test_status(self): | ||
line = "01:56 -!- ciblout [[email protected]] has quit [Quit: Bon debaras.]" | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, "status") | ||
self.assertEqual(m.message, "[[email protected]] has quit [Quit: Bon debaras.]") | ||
self.assertEqual(m.user, 'ciblout') | ||
self.assertEqual(m.time, '01:56') | ||
self.assertEqual(str(m), line) | ||
lines = [("01:56 -!- ciblout [[email protected]] has quit [Quit: Bon debaras.]", "status", "[[email protected]] has quit [Quit: Bon debaras.]", 'ciblout', '01:56'), | ||
("01:56:09 -!- ciblout [[email protected]] has quit [Quit: Bon debaras.]", "status", "[[email protected]] has quit [Quit: Bon debaras.]", 'ciblout', '01:56:09')] | ||
for line, expected_type, expected_message, expected_nick, expected_time in lines: | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, expected_type) | ||
self.assertEqual(m.message, expected_message) | ||
self.assertEqual(m.user, expected_nick) | ||
self.assertEqual(m.time, expected_time) | ||
self.assertEqual(str(m), line) | ||
|
||
def test_status_empty(self): | ||
m = self._get_FUT("01:56 -!- ciblout ") | ||
self.assertEqual(m.type, "status") | ||
self.assertEqual(m.message, "") | ||
lines = ["02:16 -!- ciblout", | ||
"02:16:45 -!- ciblout"] | ||
for line in lines: | ||
m = self._get_FUT(line) | ||
self.assertEqual(m.type, "status") | ||
self.assertEqual(m.message, "") | ||
|
||
def test_unrecognized(self): | ||
m = self._get_FUT("Ceci n'est pas une ligne de log") | ||
|
@@ -73,6 +88,8 @@ def test_exotic_nicknames(self): | |
lines = [("20:26 <K-Yo> madjar, \o/", "K-Yo"), | ||
("22:14 <+K-Yo> putain, j'ai la même!", "K-Yo"), | ||
("22:14 <@DaLynX> merci remram", "DaLynX"), | ||
("04:54 <@Zertr1> derns!", "Zertr1"), | ||
("04:54:00 <@Zertr1> derns!", "Zertr1"), | ||
("01:59 < kage> c'est moche les GUI en java", "kage")] | ||
|
||
for line, nick in lines: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters