コード例 #1
0
ファイル: models_test.py プロジェクト: AAlvz/amonlite
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()
コード例 #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()
コード例 #3
0
 def setUp(self):
     self.model = ExceptionModel()
コード例 #4
0
ファイル: models_test.py プロジェクト: AAlvz/amonlite
 def setUp(self):
     self.model = ExceptionModel()