Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

54

55

56

57

58

"""Test the basics including the bmark and tags""" 

from nose.tools import eq_ 

from nose.tools import ok_ 

from pyramid import testing 

 

from bookie.models import DBSession 

from bookie.models.applog import AppLogMgr 

 

from bookie.tests import empty_db 

from bookie.tests import TestDBBase 

from bookie.tests.factory import make_applog 

 

 

class TestAppLogMgr(TestDBBase): 

    """Verify the AppLogMgr works as expected.""" 

 

    def test_log_find(self): 

        """Verify that a basic find works""" 

        log1 = make_applog() 

        log2 = make_applog() 

        DBSession.add(log1) 

        DBSession.add(log2) 

        DBSession.flush() 

 

        found = AppLogMgr.find() 

        eq_(2, len(found)) 

 

    def test_log_find_status(self): 

        """Verify we can filter on the status field.""" 

        log1 = make_applog(status=0) 

        log2 = make_applog(status=2) 

        log3 = make_applog(status=0) 

        DBSession.add(log1) 

        DBSession.add(log2) 

        DBSession.add(log3) 

        DBSession.flush() 

 

        found = AppLogMgr.find(status=0) 

        eq_(2, len(found)) 

 

    def test_log_find_message(self): 

        """Verify we can search on the message field.""" 

        msg1 = "Auth error rharding" 

        msg2 = "Login issue rick" 

        log1 = make_applog(message=msg1) 

        log2 = make_applog(message=msg2) 

        DBSession.add(log1) 

        DBSession.add(log2) 

        DBSession.flush() 

 

        found = AppLogMgr.find(message_filter='rharding') 

        eq_(1, len(found)) 

        eq_(found[0].message, msg1) 

 

        found = AppLogMgr.find(message_filter='login') 

        eq_(1, len(found)) 

        eq_(found[0].message, msg2)