Exemplo n.º 1
0
class TestExceptionModel(unittest.TestCase):


    def setUp(self):
        self.model = ExceptionModel()


    def test_get_exceptions(self):
        self.model.collection.remove()
        self.model.collection.insert({"exception_class" : "test", "message": "test", "last_occurrence": two_minutes_ago})
        self.model.collection.insert({"exception_class" : "test", "message": "test", "last_occurrence": minute_ago})

        result = self.model.get_exceptions()
        eq_(result.count(), 2)
        
        eq_(result[0]['last_occurrence'], minute_ago)
        
        self.model.collection.remove()

    def test_delete_before_date(self):
        self.model.collection.remove()

        self.model.collection.insert({"exception_class" : "test", "message": "test", "last_occurrence": two_minutes_ago})
        self.model.collection.insert({"exception_class" : "test", "message": "test", "last_occurrence": minute_ago})
        self.model.collection.insert({"exception_class" : "test", "message": "test", "last_occurrence": now})
        
        self.model.delete_before_date(minute_ago)

        result = self.model.get_exceptions()
        eq_(result.count(), 1)

        self.model.collection.remove()
Exemplo n.º 2
0
class TestExceptionModel(unittest.TestCase):
    def setUp(self):
        self.model = ExceptionModel()

    def test_get_exceptions(self):
        self.model.collection.remove()
        self.model.collection.insert({
            "exception_class": "test",
            "message": "test",
            "last_occurrence": two_minutes_ago
        })
        self.model.collection.insert({
            "exception_class": "test",
            "message": "test",
            "last_occurrence": minute_ago
        })

        result = self.model.get_exceptions()
        eq_(result.count(), 2)

        eq_(result[0]['last_occurrence'], minute_ago)

        self.model.collection.remove()

    def test_delete_before_date(self):
        self.model.collection.remove()

        self.model.collection.insert({
            "exception_class": "test",
            "message": "test",
            "last_occurrence": two_minutes_ago
        })
        self.model.collection.insert({
            "exception_class": "test",
            "message": "test",
            "last_occurrence": minute_ago
        })
        self.model.collection.insert({
            "exception_class": "test",
            "message": "test",
            "last_occurrence": now
        })

        self.model.delete_before_date(minute_ago)

        result = self.model.get_exceptions()
        eq_(result.count(), 1)

        self.model.collection.remove()
Exemplo n.º 3
0
 def setUp(self):
     self.model = ExceptionModel()
Exemplo n.º 4
0
 def setUp(self):
     self.model = ExceptionModel()