示例#1
0
文件: tests.py 项目: rflbras/lmtt
    def test_is_expired_with_not_expired_esearch(self):
        """
        is_expired() should return False for searches whose the interval between
        now() and executed_at is lesser than or equal to EXPIRATION_DELTA.
        """

        expired_esearch = ESearch(executed_at=timezone.now())
        self.assertEqual(expired_esearch.is_expired(), False)
示例#2
0
文件: tests.py 项目: rflbras/lmtt
    def test_is_expired_with_expired_esearch(self):
        """
        is_expired() should return True for searches whose the interval between
        now() and executed_at is greater than EXPIRATION_DELTA.
        """

        expired_esearch = ESearch(
                executed_at=timezone.now() - ESearch.EXPIRATION_DELTA +
                timedelta.resolution)
        self.assertEqual(expired_esearch.is_expired(), True)
示例#3
0
文件: tests.py 项目: rflbras/lmtt
    def test_as_dict(self):
        """
        as_dict() should return a dictionary representing the model. It uses
        'year' and 'count' as labels for key_label and value_label as default.
        """

        dictionary = ESearch(term='term', executed_at=timezone.now(), key='key',
            value='value').as_dict()

        self.assertEqual(type(dictionary), type({}))
        self.assertEqual(dictionary['year'], 'key')
        self.assertEqual(dictionary['count'], 'value')
        self.assertFalse(dictionary.has_key('term'))
        self.assertFalse(dictionary.has_key('executed_at'))