コード例 #1
0
 def setUp(self):
     super(ChannelSetTestCase, self).setUp()
     self.channelset = mixer.blend(ChannelSet, editors=[self.user])
     self.channels = mixer.cycle(10).blend(
         Channel,
         secret_tokens=[self.channelset.secret_token],
         editors=[self.user])
コード例 #2
0
    def test_save_channels_to_token(self):
        """ Check endpoint will assign token to channels """
        token = self.channelset.secret_token
        channels = mixer.cycle(5).blend(Channel)
        channels = Channel.objects.filter(pk__in=[c.pk for c in channels
                                                  ])  # Make this a queryset
        token.set_channels(channels)

        # Old channels should not be included here
        for c in self.channels:
            c.refresh_from_db()
            self.assertFalse(
                c.secret_tokens.filter(token=token.token).exists())

        # New channels should be included here
        for c in channels:
            c.refresh_from_db()
            self.assertTrue(c.secret_tokens.filter(token=token.token).exists())
コード例 #3
0
 def setUp(self):
     super(ChannelMetadataSaveTestCase, self).setUp()
     self.channels = mixer.cycle(5).blend(Channel)
     for c in self.channels:
         c.main_tree.changed = False
         c.main_tree.save()
コード例 #4
0
    def setUp(self):
        super(GetAllChannelsTestCase, self).setUp()

        # create 10 channels for comparison
        self.channels = mixer.cycle(10).blend(Channel)
コード例 #5
0
ファイル: prep.py プロジェクト: priyanka-choubey/studio
from contentcuration.tests.utils import mixer

mixer.register(User, information="{}", content_defaults="{}", policies="{}")

if __name__ == "__main__":
    warnings.warn("THIS WILL CLEAR YOUR DATABASE AND FILL IT WITH TEST DATA!")
    logging.info("Clearing the DB")
    call_command("flush", "--noinput")

    # set up our DB from scratch and create our user
    logging.info("Setting up the database")
    call_command("setup")

    # create NUM_CHANNELS channels using mixer

    logging.info("Creating {} channels".format(NUM_CHANNELS))

    for _ in range(NUM_CHANNELS):
        editor = mixer.blend(User)
        c = mixer.blend(Channel)
        c.editors.add(editor)
        viewers = mixer.cycle(2).blend(User)
        for v in viewers:
            v.view_only_channels.add(c)
            v.save()
        c.save()

    # start the server in prod mode
    subprocess.call(["yarn", "run", "devserver"])