Esempio n. 1
0
class TestMultiple(object):
    def setup(self):
        states = []

        def one(args):
            if args > 0:
                return "two"
            return "three"

        def two(args):
            if args == 0:
                return "three"
            return None

        def three(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)
        self.st_three = ValueState("three", three, 3)

        states.extend([
            self.st_one,
            self.st_two,
            self.st_three
        ])

        self.mach = ValueMachination(states, self.st_one)

    def test_run_once(self):
        rv = self.mach.run({
            'one': 0,
            'three': 3
        })

        assert rv == 4

    def test_through_two(self):
        rv = self.mach.run({
            'one': 1,
            'two': 1
        })

        assert rv == 3

    def test_inc_three(self):
        rv = self.mach.run({
            'one': 1,
            'two': 0,
            'three': 4
        })

        assert rv == 6
Esempio n. 2
0
    def setup(self):
        states = []

        def one(args):
            return "two"

        def two(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)

        states.extend([self.st_one, self.st_two])

        self.mach = ValueMachination(states, self.st_one)
Esempio n. 3
0
    def setup(self):
        states = []

        def one(args):
            if args > 0:
                return "two"
            return "three"

        def two(args):
            if args == 0:
                return "three"
            return None

        def three(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)
        self.st_three = ValueState("three", three, 3)

        states.extend([
            self.st_one,
            self.st_two,
            self.st_three
        ])

        self.mach = ValueMachination(states, self.st_one)
Esempio n. 4
0
class TestEasy(object):
    def setup(self):
        states = []

        def one(args):
            return "two"

        def two(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)

        states.extend([
            self.st_one,
            self.st_two
        ])

        self.mach = ValueMachination(states, self.st_one)

    def test_run(self):
        rv = self.mach.run({
            'one': 'one',
            'two': 'two'
        })

        assert rv == 3
Esempio n. 5
0
class TestMultiple(object):
    def setup(self):
        states = []

        def one(args):
            if args > 0:
                return "two"
            return "three"

        def two(args):
            if args == 0:
                return "three"
            return None

        def three(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)
        self.st_three = ValueState("three", three, 3)

        states.extend([self.st_one, self.st_two, self.st_three])

        self.mach = ValueMachination(states, self.st_one)

    def test_run_once(self):
        rv = self.mach.run({'one': 0, 'three': 3})

        assert rv == 4

    def test_through_two(self):
        rv = self.mach.run({'one': 1, 'two': 1})

        assert rv == 3

    def test_inc_three(self):
        rv = self.mach.run({'one': 1, 'two': 0, 'three': 4})

        assert rv == 6
Esempio n. 6
0
    def setup(self):
        states = []

        def one(args):
            if args > 0:
                return "two"
            return "three"

        def two(args):
            if args == 0:
                return "three"
            return None

        def three(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)
        self.st_three = ValueState("three", three, 3)

        states.extend([self.st_one, self.st_two, self.st_three])

        self.mach = ValueMachination(states, self.st_one)
Esempio n. 7
0
    def setup(self):
        states = []

        def one(args):
            return "two"

        def two(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)

        states.extend([
            self.st_one,
            self.st_two
        ])

        self.mach = ValueMachination(states, self.st_one)
Esempio n. 8
0
class TestEasy(object):
    def setup(self):
        states = []

        def one(args):
            return "two"

        def two(args):
            return None

        self.st_one = ValueState("one", one, 1)
        self.st_two = ValueState("two", two, 2)

        states.extend([self.st_one, self.st_two])

        self.mach = ValueMachination(states, self.st_one)

    def test_run(self):
        rv = self.mach.run({'one': 'one', 'two': 'two'})

        assert rv == 3