Example #1
0
    def test_get_synced_collection(self):
        # Get a fresh synced collection.
        c = views.get_synced_collection(self.ids, "token")
        eq_(c.listed, False)
        eq_(c.type, amo.COLLECTION_SYNCHRONIZED)
        eq_(set(c.addons.values_list("id", flat=True)), set(self.ids))

        # Check that the token was set.
        eq_(c.token_set.get().token, "token")

        # Make sure we get the same collection if we try again.
        next = views.get_synced_collection(self.ids, "next")
        eq_(next.id, c.id)
        eq_(set(next.addons.values_list("id", flat=True)), set(self.ids))
        eq_(list(c.token_set.values_list("token", flat=True)), ["token", "next"])
Example #2
0
    def test_get_synced_collection_with_dupes(self):
        """It shouldn't happen, but make sure we handled synced dupes."""
        one = SyncedCollection.objects.create()
        one.set_addons(self.ids)
        two = SyncedCollection.objects.create()
        two.set_addons(self.ids)

        three = views.get_synced_collection(self.ids, 'token')
        assert one.addon_index == two.addon_index == three.addon_index
Example #3
0
 def test_get_random_token(self, uuid_mock):
     uuid_mock.side_effect = ['two', 'one', 'one', 'one'].pop
     eq_(views.get_random_token(), 'one')
     views.get_synced_collection([], 'one')
     eq_(views.get_random_token(), 'two')
Example #4
0
 def test_get_random_token(self, uuid_mock):
     uuid_mock.side_effect = ["two", "one", "one", "one"].pop
     eq_(views.get_random_token(), "one")
     views.get_synced_collection([], "one")
     eq_(views.get_random_token(), "two")