def test_refresh_handles_bad_queries(self, mocked_segment): segments.app_settings.SEGMENTS_REFRESH_ON_SAVE = False s1 = SegmentFactory() s1.definition = 'fail' s1.save() s1.refresh = Mock(return_value=True) s2 = SegmentFactory() s2.refresh = Mock(return_value=False) mocked_segment.return_value = [s1, s2] refresh_segments() self.assertEqual(s1.refresh.call_count, 1) segments.app_settings.SEGMENTS_REFRESH_ON_SAVE = True
def test_user_belongs_to_segment(self): definition = 'select * from %s where id = %s' % (user_table(), self.u.id) s = SegmentFactory(definition=definition) s.refresh() self.assertTrue(s.has_member(self.u))