# Path: turbo/flux.py
# def register(state):
#     def outwrapper(func):
#         def wrapper(*args, **kwargs):
#         def __init__(self, func):
#         def __call__(self, *args, **kwargs):
#     def __init__(self, file_attr):
#     def __get_func(self):
#     def register(self, func):
#     def __getattr__(self, name):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __init__(self, file_attr):
#     def __setattr__(self, name, value):
#     def __getattr__(self, name):
#     def _name(self):
# def dispatch(name, type_name, *args, **kwargs):
# def register_dispatch(name, type_name):
#     def outwrapper(func):
#         def wrapper(*args, **kwargs):
# class CallFuncAsAttr(object):
#     class __CallObject(object):
# class ObjectDict(dict):
# class State(object):
# class Mutation(CallFuncAsAttr):


from util import unittest
from turbo.flux import Mutation, register, dispatch, register_dispatch, State, state
def decrease_rank(rank):
    return rank - 1


@register_dispatch('flux_test', 'increase_rank')
def increase(rank):
    pass


def decrease(rank):
    return dispatch('flux_test', 'decrease_rank', rank)

tstate = State('test')
tstate.count = 0


class FluxTest(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_state(self):
        tstate.count += 1
        self.assertEqual(tstate.count, 1)
        self.assertEqual(state.test.count, 1)
        tstate.count += 1
        self.assertEqual(tstate.count, 2)

# Path: turbo/flux.py
# def register(state):
#     def outwrapper(func):
#         def wrapper(*args, **kwargs):
#         def __init__(self, func):
#         def __call__(self, *args, **kwargs):
#     def __init__(self, file_attr):
#     def __get_func(self):
#     def register(self, func):
#     def __getattr__(self, name):
#     def __getattr__(self, name):
#     def __setattr__(self, name, value):
#     def __init__(self, file_attr):
#     def __setattr__(self, name, value):
#     def __getattr__(self, name):
#     def _name(self):
# def dispatch(name, type_name, *args, **kwargs):
# def register_dispatch(name, type_name):
#     def outwrapper(func):
#         def wrapper(*args, **kwargs):
# class CallFuncAsAttr(object):
#     class __CallObject(object):
# class ObjectDict(dict):
# class State(object):
# class Mutation(CallFuncAsAttr):


# Path: tests/flux_test.py
from util import unittest
from turbo.flux import Mutation, register, dispatch, register_dispatch, State, state

def decrease_rank(rank):
    return rank - 1


@register_dispatch('flux_test', 'increase_rank')
def increase(rank):
    pass


def decrease(rank):
    return dispatch('flux_test', 'decrease_rank', rank)

tstate = State('test')
tstate.count = 0


class FluxTest(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_state(self):
        tstate.count += 1
        self.assertEqual(tstate.count, 1)
        self.assertEqual(state.test.count, 1)
        tstate.count += 1
        self.assertEqual(tstate.count, 2)

        self.assertEqual(state.test.count, 2)