def test_start_time(self):
        obj = self._add_mock_meeting()

        now = utcnow()
        now_unix = timegm(now.timetuple())

        #Shouldn't return anything
        self.assertEqual(
            self.query("start_time == %s and path == '/meeting'" %
                       now_unix)[0], 0)
        qy = ("%s < start_time < %s and path == '/meeting'" %
              (now_unix - 1, now_unix + 1))
        self.assertEqual(self.query(qy)[0], 0)

        #So let's set it and return stuff
        obj.set_field_value('start_time', now)
        from voteit.core.models.catalog import reindex_indexes
        reindex_indexes(self.root.catalog)

        self.assertEqual(
            self.query("start_time == %s and path == '/meeting'" %
                       now_unix)[0], 1)
        qy = ("%s < start_time < %s and path == '/meeting'" %
              (now_unix - 1, now_unix + 1))
        self.assertEqual(self.query(qy)[0], 1)
Beispiel #2
0
    def test_end_time(self):
        obj = self._add_mock_meeting()

        now = utcnow()
        now_unix = timegm(now.timetuple())
        
        obj.set_field_value('end_time', now)
        from voteit.core.models.catalog import reindex_indexes
        reindex_indexes(self.root.catalog)
        
        self.assertEqual(self.query("end_time == %s and path == '/meeting'" % now_unix)[0], 1)
        qy = ("%s < end_time < %s and path == '/meeting'" % (now_unix-1, now_unix+1))
        self.assertEqual(self.query(qy)[0], 1)
    def test_end_time(self):
        obj = self._add_mock_meeting()

        now = utcnow()
        now_unix = timegm(now.timetuple())

        obj.set_field_value('end_time', now)
        from voteit.core.models.catalog import reindex_indexes
        reindex_indexes(self.root.catalog)

        self.assertEqual(
            self.query("end_time == %s and path == '/meeting'" % now_unix)[0],
            1)
        qy = ("%s < end_time < %s and path == '/meeting'" %
              (now_unix - 1, now_unix + 1))
        self.assertEqual(self.query(qy)[0], 1)
    def test_reindex_indexes(self):
        meeting = createContent('Meeting')
        meeting.title = 'hello world'
        self.root['meeting'] = meeting
        catalog = self.root.catalog

        #Catalog should return the meeting on a search
        self.assertEqual(self.query("title == 'hello world'")[0], 1)

        #If the meeting title changes, no subscriber will be fired here...
        meeting.title = "Goodbye cruel world"
        #...but when reindexed it should work
        from voteit.core.models.catalog import reindex_indexes
        reindex_indexes(catalog)

        self.assertEqual(self.query("title == 'Goodbye cruel world'")[0], 1)
Beispiel #5
0
 def test_reindex_indexes(self):
     meeting = createContent('Meeting')
     meeting.title = 'hello world'
     self.root['meeting'] = meeting
     catalog = self.root.catalog
     
     #Catalog should return the meeting on a search
     self.assertEqual(self.query("title == 'hello world'")[0], 1)
     
     #If the meeting title changes, no subscriber will be fired here...
     meeting.title = "Goodbye cruel world"
     #...but when reindexed it should work
     from voteit.core.models.catalog import reindex_indexes
     reindex_indexes(catalog)
     
     self.assertEqual(self.query("title == 'Goodbye cruel world'")[0], 1)
Beispiel #6
0
 def _extra_fixtures(self, root):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.discussion_post import DiscussionPost
     from voteit.core.models.catalog import reindex_indexes
     settings = self.config.registry.settings
     settings['default_locale_name'] = 'sv'
     settings['default_timezone_name'] = 'Europe/Stockholm'
     self.config.include('voteit.core.models.date_time_util')
     root['m']['p1'] = Proposal(creators = ['admin'])
     root['m']['p1'].title = u"Prop p1"
     root['m']['d1'] = DiscussionPost(creators = ['admin'])
     root['m']['d1'].title = u"Disc d1"
     root['m2'] = Meeting()
     root['m2']['p2'] = Proposal(creators = ['admin'])
     root['m2']['p2'].title = u"Prop p2"
     root['m2']['d2'] = DiscussionPost(creators = ['admin'])
     root['m2']['d2'].title = u"Disc d2"
     reindex_indexes(root.catalog)
 def _extra_fixtures(self, root):
     from voteit.core.models.meeting import Meeting
     from voteit.core.models.proposal import Proposal
     from voteit.core.models.discussion_post import DiscussionPost
     from voteit.core.models.catalog import reindex_indexes
     settings = self.config.registry.settings
     settings['default_locale_name'] = 'sv'
     settings['default_timezone_name'] = 'Europe/Stockholm'
     self.config.include('voteit.core.models.date_time_util')
     root['m']['p1'] = Proposal(creators=['admin'])
     root['m']['p1'].title = u"Prop p1"
     root['m']['d1'] = DiscussionPost(creators=['admin'])
     root['m']['d1'].title = u"Disc d1"
     root['m2'] = Meeting()
     root['m2']['p2'] = Proposal(creators=['admin'])
     root['m2']['p2'].title = u"Prop p2"
     root['m2']['d2'] = DiscussionPost(creators=['admin'])
     root['m2']['d2'].title = u"Disc d2"
     reindex_indexes(root.catalog)
    def test_unread(self):
        meeting = self._add_mock_meeting()
        self._register_security_policies()
        self.config.include('voteit.core.models.unread')
        #Discussion posts are unread aware
        from voteit.core.models.discussion_post import DiscussionPost
        obj = DiscussionPost()
        obj.title = 'Hello'
        meeting['post'] = obj

        from voteit.core.models.catalog import reindex_indexes
        reindex_indexes(self.root.catalog)

        self.assertEqual(self.search(unread='admin')[0], 1)

        unread = self.config.registry.queryAdapter(obj, IUnread)
        unread.mark_as_read('admin')

        self.assertEqual(self.search(unread='admin')[0], 0)
Beispiel #9
0
 def test_unread(self):
     meeting = self._add_mock_meeting()
     self._register_security_policies()
     self.config.include('voteit.core.models.unread')
     #Discussion posts are unread aware
     from voteit.core.models.discussion_post import DiscussionPost
     obj = DiscussionPost()
     obj.title = 'Hello'
     meeting['post'] = obj
     
     from voteit.core.models.catalog import reindex_indexes
     reindex_indexes(self.root.catalog)
     
     self.assertEqual(self.search(unread='admin')[0], 1)
     
     unread = self.config.registry.queryAdapter(obj, IUnread)
     unread.mark_as_read('admin')
     
     self.assertEqual(self.search(unread='admin')[0], 0)
Beispiel #10
0
    def test_start_time(self):
        obj = self._add_mock_meeting()

        now = utcnow()
        now_unix = timegm(now.timetuple())
        
        #Shouldn't return anything
        self.assertEqual(self.query("start_time == %s and path == '/meeting'" % now_unix)[0], 0)
        qy = ("%s < start_time < %s and path == '/meeting'" % (now_unix-1, now_unix+1))
        self.assertEqual(self.query(qy)[0], 0)
        
        #So let's set it and return stuff
        obj.set_field_value('start_time', now)
        from voteit.core.models.catalog import reindex_indexes
        reindex_indexes(self.root.catalog)
        
        self.assertEqual(self.query("start_time == %s and path == '/meeting'" % now_unix)[0], 1)
        qy = ("%s < start_time < %s and path == '/meeting'" % (now_unix-1, now_unix+1))
        self.assertEqual(self.query(qy)[0], 1)