def test_object_provides_behavior_indexed(self): pc = self.portal.portal_catalog self.assertEquals(pc.uniqueValuesFor('visits'), (0,)) overrideAdaptersAndUtilities(self.context_behavior) view = self.context_behavior.restrictedTraverse("@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (200,)) view = self.context_no_behavior.restrictedTraverse("@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (200,))
def test_object_provides_behavior_indexed(self): pc = self.portal.portal_catalog self.assertEquals(pc.uniqueValuesFor('visits'), (0, )) overrideAdaptersAndUtilities(self.context_behavior) view = self.context_behavior.restrictedTraverse( "@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (200, )) view = self.context_no_behavior.restrictedTraverse( "@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (200, ))
def test_invalid_read_no_override_old_value(self): pc = self.portal.portal_catalog self.context_behavior.visits = 120 self.context_behavior.reindexObject(idxs=['visits',]) self.assertEquals(pc.uniqueValuesFor('visits'), (120,)) view = self.context_behavior.restrictedTraverse("@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (120,)) overrideAdaptersAndUtilities(self.context_behavior) view = self.context_behavior.restrictedTraverse("@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (200,))
def test_provide_both_dates_to_override(self): overrideAdaptersAndUtilities(self.context) analytics_tool = self.context.portal_analytics request = self.layer['request'] view = self.context.restrictedTraverse("@@update-visits-counter") view() start_date = request.get('start_date') end_date = request.get('end_date') date = self.context.created().strftime('%Y%m%d') self.assertEquals(start_date, date) self.assertEquals(end_date, date) report = analytics_tool['collective-gavisits-visits'] report.start_date = '20010101' view() start_date = request.get('start_date') end_date = request.get('end_date') self.assertEquals(start_date, date) self.assertNotEquals(start_date, '20010101') self.assertEquals(end_date, date) report.end_date = '20010101' view() start_date = request.get('start_date') end_date = request.get('end_date') self.assertNotEquals(start_date, date) self.assertEquals(start_date, '20010101') self.assertNotEquals(end_date, date) self.assertEquals(end_date, '20010101')
def test_invalid_read_no_override_old_value(self): pc = self.portal.portal_catalog self.context_behavior.visits = 120 self.context_behavior.reindexObject(idxs=[ 'visits', ]) self.assertEquals(pc.uniqueValuesFor('visits'), (120, )) view = self.context_behavior.restrictedTraverse( "@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (120, )) overrideAdaptersAndUtilities(self.context_behavior) view = self.context_behavior.restrictedTraverse( "@@update-visits-counter") view() self.assertEquals(pc.uniqueValuesFor('visits'), (200, ))
def test_view_results_valid_data(self): overrideAdaptersAndUtilities(self.context) view = self.context.restrictedTraverse("@@update-visits-counter") results = view() self.assertEquals(results, '{"visits": 200}')
def test_get_visits_valid_ga_account(self): overrideAdaptersAndUtilities(self.context) view = self.context.restrictedTraverse("@@update-visits-counter") self.assertEquals(view.get_visits(), 200)