Exemple #1
0
 def test_retrieve_a_variant(self):
     fn = "FOO"
     _variants = ["foo", "bar", "bazz"]
     self.backend.add_functionality(Feature(fn, variants=_variants))
     f = self.backend.get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(100)
     self.backend.variant(fn, 'juan') | should.be_in(f.variants)
     self.backend.variant(fn, 'juan2') | should.be_in(f.variants)
Exemple #2
0
 def test_retrieve_a_variant(self):
     fn = "FOO"
     _variants = ["foo", "bar", "bazz"]
     self.backend.add_functionality(Feature(fn, variants=_variants))
     f = self.backend.get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(100)
     self.backend.variant(fn, 'juan') | should.be_in(f.variants)
     self.backend.variant(fn, 'juan2') | should.be_in(f.variants)
Exemple #3
0
    def test_executes_catch_only_upon_exception_raised(self):
        @coroutine
        def to_xxx(destination=None):
            while True:
                value = yield
                v = value.to_xxx()
                if destination is not None:
                    destination.send(v)

        class Foo(object):
            def __init__(self, value):
                self.value = value

            def to_xxx(self):
                return self

            def __repr__(self):
                return self.value

        register(to_xxx)

        values = (Foo('10'), Foo('20'), Foo('30'), '1', '2')

        _pipeline = (pipeline((x for x in values)).to_xxx().catch(
            collect(self.recollector)).collect(self.recollector))

        _pipeline()

        all_of([x for (i, x) in enumerate(values) if i < 4]) | should.be_in(
            self.recollector)

        len(self.recollector) | should.be(4)
Exemple #4
0
 def test_add_a_functionality_with_variants(self):
     fn = "FOO"
     _variants = ["foo", "bar", "bazz"]
     self.backend.add_functionality(Feature(fn, variants=_variants))
     f = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(100)
     all_of(["foo", "bar", "bazz"]) | should.be_in(f.variants)
Exemple #5
0
 def test_add_a_functionality_with_variants(self):
     fn = "FOO"
     _variants = ["foo", "bar", "bazz"]
     self.backend.add_functionality(Feature(fn, variants=_variants))
     f = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(100)
     all_of(["foo", "bar", "bazz"]) | should.be_in(f.variants)
Exemple #6
0
    def is_running(self):
        start_sbo = os.getenv("TEST_ACCEPTANCE_START_SBO")
        start_sbo | should_not.be_none.desc("TEST_ACCEPTANCE_START_SBO is set")
        start_sbo | should.be_in({"local", "operator-hub"})

        if start_sbo == "local":
            os.getenv("TEST_ACCEPTANCE_SBO_STARTED") | should_not.start_with("FAILED").desc("TEST_ACCEPTANCE_SBO_STARTED is not FAILED")
        elif start_sbo == "operator-hub":
            return False

        return self.check_resources()
Exemple #7
0
    def test_executes_catch_upon_exception_raised(self):
        @coroutine
        def to_xxx(destination=None):
            while True:
                value = yield
                value.to_xxx()

        register(to_xxx)

        _pipeline = (pipeline(
            (x for x in ('foo', 'bar', 'bazz'))).uppercase().to_xxx().catch(
                collect(self.recollector)))

        _pipeline()
        'FOO' | should.be_in(self.recollector)
        len(self.recollector) | should.be(1)
Exemple #8
0
    def test_executes_catch_upon_exception_raised(self):
        @coroutine
        def to_xxx(destination=None):
            while True:
                value = yield
                value.to_xxx()

        register(to_xxx)

        _pipeline = (
            pipeline((x for x in ('foo', 'bar', 'bazz')))
            .uppercase()
            .to_xxx()
            .catch(collect(self.recollector))
        )

        _pipeline()
        'FOO' | should.be_in(self.recollector)
        len(self.recollector) | should.be(1)
Exemple #9
0
    def test_executes_catch_only_upon_exception_raised(self):

        @coroutine
        def to_xxx(destination=None):
            while True:
                value = yield
                v = value.to_xxx()
                if destination is not None:
                    destination.send(v)

        class Foo(object):

            def __init__(self, value):
                self.value = value

            def to_xxx(self):
                return self

            def __repr__(self):
                return self.value

        register(to_xxx)

        values = (Foo('10'), Foo('20'), Foo('30'), '1', '2')

        _pipeline = (
            pipeline((x for x in values))
            .to_xxx()
            .catch(collect(self.recollector))
            .collect(self.recollector)
        )

        _pipeline()

        all_of(
            [x for (i, x) in enumerate(values) if i < 4]
        ) | should.be_in(self.recollector)

        len(self.recollector) | should.be(4)
Exemple #10
0
 def test_chains_coroutines(self):
     self.pipeline()
     all_of(('FOO', 'BAR', 'BAZZ')) | should.be_in(self.recollector)
     len(self.recollector) | should.be(3)
Exemple #11
0
 def test_create_feature_with_variants(self):
     FN = 'bar'
     _variants = ['BAR', 'BAZZ']
     self.rollout.add_func(FN, variants=_variants)
     self.rollout.set_percentage(FN, 100)
     self.rollout.variant('bar', 'user') | should.be_in(_variants)
Exemple #12
0
 def test_register_two_functionalities(self):
     self.rollout.add_func('bar', lambda x: x.id, percentage=0)
     self.rollout.backend.get_functionalities() | should.have_len(2)
     all_of([self.FN, 'bar']) | should.be_in(self.rollout.backend.get_functionalities())
Exemple #13
0
 def test_chains_coroutines(self):
     self.pipeline()
     all_of(('FOO', 'BAR', 'BAZZ')) | should.be_in(self.recollector)
     len(self.recollector) | should.be(3)