def test_broadcast(self):
     c1 = Channel("c1")
     phone_numbers = list()
     channels = [c1]
     followings = [Following("u1", "c1")]
     self.assertIsNone(c1.phone_number)
     c1.broadcast(phone_numbers, channels, followings)
     self.assertIsNotNone(c1.phone_number)
 def test_minimum_phone_numbers_used(self):
     c1 = Channel("c1")
     c2 = Channel("c2")
     phone_numbers = list()
     channels = [c1, c2]
     followings = [Following("u1", "c1"), Following("u2", "c2")]
     phone_numbers = c1.broadcast(phone_numbers, channels, followings)
     self.assertEqual(len(phone_numbers), 1)
     phone_numbers = c2.broadcast(phone_numbers, channels, followings)
     self.assertEqual(len(phone_numbers), 1)
    def test_follow_channel_without_collision(self):
        c1 = Channel("c1")
        c2 = Channel("c2")
        u2 = User("u2")
        phone_numbers = list()
        channels = [c1, c2]
        followings = [Following("u1", "c1")]
        phone_numbers = c1.broadcast(phone_numbers, channels, followings)
        phone_numbers = c2.broadcast(phone_numbers, channels, followings)

        u2.follow_channel("c2", channels, phone_numbers, followings)
        self.assertEqual(c1.phone_number, c2.phone_number)
Ejemplo n.º 4
0
phone_numbers = list()

phone_numbers = c1.broadcast(phone_numbers, channels, followings)
phone_numbers = c3.broadcast(phone_numbers, channels, followings)
phone_numbers = c1.broadcast(phone_numbers, channels, followings)
phone_numbers = c2.broadcast(phone_numbers, channels, followings)
phone_numbers = c2.broadcast(phone_numbers, channels, followings)
phone_numbers = c2.broadcast(phone_numbers, channels, followings)

followings, phone_numbers = u2.follow_channel(c1.channel_uid, channels,
                                              phone_numbers, followings)
# followings, phone_numbers = u2.follow_channel(c3.channel_uid, channels, phone_numbers, followings)

c4 = Channel("c4")
channels.append(c4)
phone_numbers = c4.broadcast(phone_numbers, channels, followings)
phone_numbers = c4.broadcast(phone_numbers, channels, followings)

followings, phone_numbers = u1.follow_channel(c4.channel_uid, channels,
                                              phone_numbers, followings)
followings, phone_numbers = u3.follow_channel(c4.channel_uid, channels,
                                              phone_numbers, followings)

c5 = Channel("c5")
channels.append(c5)

u5 = User("u5")
users.append(u5)
followings, phone_numbers = u5.follow_channel(c5.channel_uid, channels,
                                              phone_numbers, followings)
phone_numbers = c5.broadcast(phone_numbers, channels, followings)