示例#1
0
    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)})
示例#2
0
 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)
示例#3
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)
示例#4
0
 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)
示例#5
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)
示例#6
0
 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))
示例#7
0
 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)
示例#8
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))
示例#9
0
 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))
示例#10
0
 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))
示例#11
0
 def test_user_adds_to_segment(self):
     s = SegmentFactory()
     s.add_member(self.u)
     self.assertTrue(s.has_member(self.u))
示例#12
0
 def test_user_adds_to_segment(self):
     s = SegmentFactory()
     s.add_member(self.u)
     self.assertTrue(s.has_member(self.u))