Example #1
0
 def setUp(self):
     self.model = UnreadModel()
Example #2
0
 def setUp(self):
     self.model = UnreadModel()
Example #3
0
class TestUnreadModel(unittest.TestCase):
    def setUp(self):
        self.model = UnreadModel()

    def test_unread(self):
        self.model.collection.remove()
        unread = self.model.get_unread_values()

        eq_(1, unread['id'])

        # Check if there is a log and exception field
        eq_(True, unread.has_key('logs'))
        eq_(True, unread.has_key('exceptions'))

    def test_mark_logs_as_read(self):
        self.model.get_unread_values(
        )  # It will create the record if it doesn't exist
        self.model.collection.update({"id": 1}, {"$inc": {"logs": 1}})

        self.model.mark_logs_as_read()

        result = self.model.get_unread_values()
        eq_(result['logs'], 0)

    def test_mark_exceptions_as_read(self):
        self.model.get_unread_values(
        )  # It will create the record if it doesn't exist
        self.model.collection.update({"id": 1}, {"$inc": {"exceptions": 1}})

        self.model.mark_exceptions_as_read()

        result = self.model.get_unread_values()
        eq_(result['exceptions'], 0)
Example #4
0
class TestUnreadModel(unittest.TestCase):
    def setUp(self):
        self.model = UnreadModel()

    def test_unread(self):
        self.model.collection.remove()
        unread = self.model.get_unread_values()

        eq_(1, unread["id"])

        # Check if there is a log and exception field
        eq_(True, unread.has_key("logs"))
        eq_(True, unread.has_key("exceptions"))

    def test_mark_logs_as_read(self):
        self.model.get_unread_values()  # It will create the record if it doesn't exist
        self.model.collection.update({"id": 1}, {"$inc": {"logs": 1}})

        self.model.mark_logs_as_read()

        result = self.model.get_unread_values()
        eq_(result["logs"], 0)

    def test_mark_exceptions_as_read(self):
        self.model.get_unread_values()  # It will create the record if it doesn't exist
        self.model.collection.update({"id": 1}, {"$inc": {"exceptions": 1}})

        self.model.mark_exceptions_as_read()

        result = self.model.get_unread_values()
        eq_(result["exceptions"], 0)