예제 #1
0
    def test_language_filter(self):
        script = CacheRepresentationPerLane(self._db, [
            "--language=fre", "--language=English", "--language=none",
            "--min-depth=0"
        ],
                                            testing=True)
        eq_(['fre', 'eng'], script.languages)

        english_lane = Lane(self._db,
                            self._default_library,
                            self._str,
                            languages=['eng'])
        eq_(True, script.should_process_lane(english_lane))

        no_english_lane = Lane(self._db,
                               self._default_library,
                               self._str,
                               exclude_languages=['eng'])
        eq_(True, script.should_process_lane(no_english_lane))

        no_english_or_french_lane = Lane(self._db,
                                         self._default_library,
                                         self._str,
                                         exclude_languages=['eng', 'fre'])
        eq_(False, script.should_process_lane(no_english_or_french_lane))
예제 #2
0
    def test_should_process_lane(self):

        # Test that should_process_lane respects any specified
        # language restrictions.
        script = CacheRepresentationPerLane(
            self._db, ["--language=fre", "--language=English", "--language=none", "--min-depth=0"],
            manager=object()
        )
        eq_(['fre', 'eng'], script.languages)

        english_lane = self._lane(languages=['eng'])
        eq_(True, script.should_process_lane(english_lane))

        no_english_lane = self._lane(languages=['spa','fre'])
        eq_(True, script.should_process_lane(no_english_lane))

        no_english_or_french_lane = self._lane(languages=['spa'])
        eq_(False, script.should_process_lane(no_english_or_french_lane))

        # Test that should_process_lane respects maximum depth
        # restrictions.
        script = CacheRepresentationPerLane(
            self._db, ["--max-depth=0", "--min-depth=0"],
            manager=object()
        )
        eq_(0, script.max_depth)

        child = self._lane(display_name="sublane")
        parent = self._lane(display_name="parent")
        parent.sublanes=[child]
        eq_(True, script.should_process_lane(parent))
        eq_(False, script.should_process_lane(child))

        script = CacheRepresentationPerLane(
            self._db, ["--min-depth=1"], testing=True
        )
        eq_(1, script.min_depth)
        eq_(False, script.should_process_lane(parent))
        eq_(True, script.should_process_lane(child))
예제 #3
0
    def test_max_and_min_depth(self):
        with self.temp_config() as config:
            script = CacheRepresentationPerLane(
                self._db, ["--max-depth=0", "--min-depth=0"], testing=True)
            eq_(0, script.max_depth)

            child = Lane(self._db, "sublane")
            parent = Lane(self._db, "parent", sublanes=[child])
            eq_(True, script.should_process_lane(parent))
            eq_(False, script.should_process_lane(child))

            script = CacheRepresentationPerLane(self._db, ["--min-depth=1"],
                                                testing=True)
            eq_(1, script.min_depth)
            eq_(False, script.should_process_lane(parent))
            eq_(True, script.should_process_lane(child))
예제 #4
0
    def test_max_and_min_depth(self):
        script = CacheRepresentationPerLane(self._db,
                                            ["--max-depth=0", "--min-depth=0"],
                                            testing=True)
        eq_(0, script.max_depth)

        child = self._lane(display_name="sublane")
        parent = self._lane(display_name="parent")
        parent.sublanes = [child]
        eq_(True, script.should_process_lane(parent))
        eq_(False, script.should_process_lane(child))

        script = CacheRepresentationPerLane(self._db, ["--min-depth=1"],
                                            testing=True)
        eq_(1, script.min_depth)
        eq_(False, script.should_process_lane(parent))
        eq_(True, script.should_process_lane(child))
예제 #5
0
 def test_default_pagination(self):
     # By default, do_generate will only be called once, with pagination=None.
     script = CacheRepresentationPerLane(
         self._db, manager=object(), cmd_args=[]
     )
     eq_([None], list(script.pagination(object())))
예제 #6
0
 def test_default_pagination(self):
     # By default, do_generate will only be called once, with pagination=None.
     script = CacheRepresentationPerLane(
         self._db, manager=object(), cmd_args=[]
     )
     eq_([None], list(script.pagination(object())))
예제 #7
0
    def test_should_process_lane(self):

        # Test that should_process_lane respects any specified
        # language restrictions.
        script = CacheRepresentationPerLane(
            self._db, ["--language=fre", "--language=English", "--language=none", "--min-depth=0"],
            manager=object()
        )
        eq_(['fre', 'eng'], script.languages)

        english_lane = self._lane(languages=['eng'])
        eq_(True, script.should_process_lane(english_lane))

        no_english_lane = self._lane(languages=['spa','fre'])
        eq_(True, script.should_process_lane(no_english_lane))

        no_english_or_french_lane = self._lane(languages=['spa'])
        eq_(False, script.should_process_lane(no_english_or_french_lane))

        # Test that should_process_lane respects maximum depth
        # restrictions.
        script = CacheRepresentationPerLane(
            self._db, ["--max-depth=0", "--min-depth=0"],
            manager=object()
        )
        eq_(0, script.max_depth)

        child = self._lane(display_name="sublane")
        parent = self._lane(display_name="parent")
        parent.sublanes=[child]
        eq_(True, script.should_process_lane(parent))
        eq_(False, script.should_process_lane(child))

        script = CacheRepresentationPerLane(
            self._db, ["--min-depth=1"], testing=True
        )
        eq_(1, script.min_depth)
        eq_(False, script.should_process_lane(parent))
        eq_(True, script.should_process_lane(child))