def testSingleComplexSelector(self):
        intended_list = ['a', 'b', 'c']
        out_list = bbutil.list_select(self.test_list, '1-3')
        reason = "Did not expect %s as a result for the selector '1-3'"
        self.assertEquals(out_list, intended_list, reason % out_list)

        intended_list = ['c', 'd', 'e']
        out_list = bbutil.list_select(self.test_list, '3-5')
        reason = "Did not expect %s as a result for the selector '3-5'"
        self.assertEquals(out_list, intended_list, reason % out_list)
    def play(self, anim=None, selector=None):
        """ Record command, start playing an animation

        Can play a certain (named) animation or the current one by default.
        Also can play only a part of an animation if *start* and/or *end* are defined

        :param anim: Animation-Name, defaults to the current animation
        :type anim: str or None
        :param selector: A selector specifying what keyframes of the Animation should be included
        :type selector: str
        :return: Success of the operation
        """

        # If no anim given, we use the current one
        if not anim:
            if not self.current.anim:
                self.log.info("Refusing to play, because nothing to play exists!")
                return False
            anim_dict = {
                "name": "Record-play",
                "keyframes": self.current.anim
            }
            self.log.debug("playing current animation")
        # If anim given, we load it
        else:
            self.log.debug("loading animation %s" % anim)
            anim_dict = self.retrieve_animation(anim)

            # ensure the retrieval was a success
            if not anim_dict:
                self.log.warning("Retrieval of animation %s failed!" % anim)
                return False

        # Filter the Keyframelist when a selector is given
        if selector:
            self.log.debug("Filtering the Keyframelist based on: '%s' ..." % selector)
            cropped_list = list_select(anim_dict['keyframes'], selector)
            if not cropped_list:
                self.log.warning("not playing, because something went wrong selecting the keyframes")
                return False
            anim_dict['keyframes'] = cropped_list

        self.log.info("Spiele %d Stellungen ab..." % len(anim_dict['keyframes']))
        return self.execute_play(anim_dict)
 def testFaultySelector(self):
     intended_list = []
     out_list = bbutil.list_select(self.test_list, 'x-y')
     reason = "Did expect a failure and not %s as a result for the selector 'x-y'"
     self.assertEquals(out_list, intended_list, reason % out_list)
 def testOneElementComplexSelector(self):
     intended_list = ['d']
     out_list = bbutil.list_select(self.test_list, '4-4')
     reason = "Did not not expect %s as a result for the selector '4-4'"
     self.assertEquals(out_list, intended_list, reason % out_list)
 def testMixedSelectors(self):
     intended_list = ['a', 'c', 'd', 'f']
     out_list = bbutil.list_select(self.test_list, '1,3-4,6')
     reason = "Did not not expect %s as a result for the selector '1,3-4,6'"
     self.assertEquals(out_list, intended_list, reason % out_list)
 def testOutOfBoundsComplexSelector(self):
     intended_list = []
     out_list = bbutil.list_select(self.test_list, '1-7')
     reason = "Did expect a failure and not %s as a result for the selector '1-7'"
     self.assertEquals(out_list, intended_list, reason % out_list)
 def testWronglyOrderedComplexSelector(self):
     intended_list = []
     out_list = bbutil.list_select(self.test_list, '5-1')
     reason = "Did expect a failure and not %s as a result for the selector '5-1'"
     self.assertEquals(out_list, intended_list, reason % out_list)