def test_diff_segment(self): s1 = SegmentFactory() u1 = UserFactory() s1.add_member(u1) s2 = SegmentFactory() u2 = UserFactory() s2.add_member(u1) s2.add_member(u2) s1_key = self.helper.segment_key % s1.id s2_key = self.helper.segment_key % s2.id self.helper.diff_segment(s2_key, s1_key, 'diff_test') self.assertEquals(self.helper.redis.smembers('diff_test'), {str(u2.id)})
def test_get_segment_members_invalid_segment(self): s = SegmentFactory() s.add_member(self.user) members = self.helper.get_segment_members(99999) self.assertEquals(len(list(members)), 0)
def test_delete_segment(self, p_delete_segment): s = SegmentFactory() s.add_member(self.user) s.delete() self.assertFalse(self.helper.segment_has_member(s.id, self.user.id)) self.assertTrue(p_delete_segment.called)
def test_get_user_segments_when_invalid_user(self): s = SegmentFactory() s.add_member(self.user) segments = self.helper.get_user_segments(9999) self.assertEquals(len(segments), 0)
def test_get_segment_membership_count(self): s = SegmentFactory() s.add_member(self.user) self.assertEquals(self.helper.get_segment_membership_count(s.id), 1)
def test_remove_segment_membership_segment_exists(self): s = SegmentFactory() s.add_member(self.user) self.helper.remove_segment_membership(s.id, self.user.id) self.assertFalse(self.helper.segment_has_member(s.id, self.user.id))
def test_get_user_segments_when_segment_exists(self): s = SegmentFactory() s.add_member(self.user) segments = self.helper.get_user_segments(self.user.id) self.assertTrue(len(segments) > 0)
def test_segment_has_member_nonexistant_segment(self): s = SegmentFactory() s.add_member(self.user) self.helper.remove_segment_membership(99999, self.user.id) self.assertTrue(self.helper.segment_has_member(s.id, self.user.id))
def test_segment_has_member_when_segment_exists(self): s = SegmentFactory() s.add_member(self.user) self.assertTrue(self.helper.segment_has_member(s.id, self.user.id))
def test_add_segment_membership(self): s = SegmentFactory() s.add_member(self.user) self.assertTrue(self.helper.segment_has_member(s.id, self.user.id))
def test_user_adds_to_segment(self): s = SegmentFactory() s.add_member(self.u) self.assertTrue(s.has_member(self.u))