コード例 #1
0
 def test_logout_first(self):
     logline = "987: logout other_user"
     chain = LoginEvent(LogoutEvent(SessionEvent()))
     expected = {
         "id": "987",
         "type": LogoutEvent.__name__,
         "value": "other_user",
     }
     self.assertDictEqual(chain.process(logline), expected)
コード例 #2
0
    def test_login_first(self):
        logline = "567: login User"
        chain = LogoutEvent(LoginEvent(SessionEvent()))
        result = chain.process(logline)
        expected = {"id": "567", "type": LoginEvent.__name__, "value": "User"}

        self.assertEqual(result, expected)
コード例 #3
0
 def test_generic_first(self):
     cases = ("123: login user", "123: logout user")
     expected = {
         "id": "123",
         "type": SessionEvent.__name__,
         "value": "user",
     }
     chain = SessionEvent(LoginEvent(LogoutEvent()))
     for logline in cases:
         with self.subTest(logline=logline):
             self.assertDictEqual(chain.process(logline), expected)
コード例 #4
0
    def test_login(self):
        logline = "567: login User"
        chain = LogoutEvent(LoginEvent())
        expected = {"id": "567", "type": LoginEvent.__name__, "value": "User"}

        self.assertEqual(chain.process(logline), expected)
コード例 #5
0
 def test_no_reception(self):
     logline = "no event can match this log"
     chain = LoginEvent(LogoutEvent(SessionEvent()))
     self.assertIsNone(chain.process(logline))
コード例 #6
0
    def test_match_login_event(self):
        logline = "1234: login John"
        expected = {"id": "1234", "value": "John"}

        self.assertTrue(LoginEvent.can_process(logline))
        self.assertDictEqual(LoginEvent._parse_data(logline), expected)