Exemplo n.º 1
0
 def test_add_a_functionality_with_percentage(self):
     fn = "FOO"
     self.backend.add_functionality(Feature(fn, None, 50))
     self.backend.get_functionalities() | should.have_len(1)
     f, users = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(50)
     users | should.be_empty().and_array()
Exemplo n.º 2
0
 def test_add_a_functionality_with_percentage(self):
     fn = "FOO"
     self.backend.add_functionality(Feature(fn, None, 50))
     self.backend.get_functionalities() | should.have_len(1)
     f, users = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(50)
     users | should.be_empty().and_array()
Exemplo n.º 3
0
 def test_add_a_disabled_functionality_with_percentage(self):
     fn = "FOO"
     func = Feature(fn, None, 50)
     func.enabled = False
     self.backend.add_functionality(func)
     f = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(50)
     f.enabled | should.be_falsy()
     self.backend._redis.smembers("rollout:users:FOO") | should.be_empty()
Exemplo n.º 4
0
 def test_add_existing_an_user(self):
     fn = "FOO"
     self.backend.add_functionality(Feature(fn))
     self.backend.get_functionalities() | should.have_len(1)
     f, users = self.backend._get_functionality(fn)
     users | should.be_empty().and_array()
     self.backend.add(fn, "bar")
     self.backend.add(fn, "bar")
     f, users = self.backend._get_functionality(fn)
     users | should.eql(['bar'])
Exemplo n.º 5
0
 def test_add_a_disabled_functionality_with_percentage(self):
     fn = "FOO"
     func = Feature(fn, None, 50)
     func.enabled = False
     self.backend.add_functionality(func)
     f = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(50)
     f.enabled | should.be_falsy()
     self.backend._redis.smembers("rollout:users:FOO") | should.be_empty()
Exemplo n.º 6
0
 def test_add_existing_an_user(self):
     fn = "FOO"
     self.backend.add_functionality(Feature(fn))
     self.backend.get_functionalities() | should.have_len(1)
     f, users = self.backend._get_functionality(fn)
     users | should.be_empty().and_array()
     self.backend.add(fn, "bar")
     self.backend.add(fn, "bar")
     f, users = self.backend._get_functionality(fn)
     users | should.eql(['bar'])
Exemplo n.º 7
0
 def test_add_a_disabled_functionality_with_percentage(self):
     fn = "FOO"
     func = Feature(fn, None, 50)
     func.enabled = False
     self.backend.add_functionality(func)
     self.backend.get_functionalities() | should.have_len(1)
     f, users = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(50)
     f.enabled | should.be_falsy()
     users | should.be_empty().and_array()
Exemplo n.º 8
0
 def test_add_a_disabled_functionality_with_percentage(self):
     fn = "FOO"
     func = Feature(fn, None, 50)
     func.enabled = False
     self.backend.add_functionality(func)
     self.backend.get_functionalities() | should.have_len(1)
     f, users = self.backend._get_functionality(fn)
     f.name | should.eql(fn)
     f.percentage | should.eql(50)
     f.enabled | should.be_falsy()
     users | should.be_empty().and_array()
Exemplo n.º 9
0
def test_decorator():
    class T(FailureModeResolver):
        @failure_mode
        def failing(self):
            """foobar"""
            return []

    T.failing | should.be_an_instance_of(UnboundFailureMode)

    t = T()
    t.failing | should.be_an_instance_of(FailureMode)
    t.failing.arguments | should.be_empty()
    t.failing.description | should.be_equal('foobar')
Exemplo n.º 10
0
def test_parse_basic():
    graph = parse('''
        // @state A
        // @state B
        // @transition A -> B
    ''')

    graph | should.be_instance_of(StateGraph)

    graph.states | should.have_length(2)
    graph.states[0].id | should.be_equal('A')
    graph.states[1].id | should.be_equal('B')

    graph.transitions | should.have_length(1)
    graph.transitions[0].from_state.id | should.be_equal('A')
    graph.transitions[0].to_state.id | should.be_equal('B')
    graph.transitions[0].triggers | should.be_empty()
Exemplo n.º 11
0
 def test_retrieve_empty_array_when_nofuncionality_added(self):
     self.backend.get_functionalities() | should.be_empty()
Exemplo n.º 12
0
 def test_retrieve_empty_array_when_nofuncionality_added(self):
     self.backend.get_functionalities() | should.be_empty()