# Path: jinja2schema/order_number.py
# class OrderNumber(object):
#     """A base Order Number class.
# 
#     .. attribute:: number
# 
#         Initial counter value.
# 
#     .. attribute:: enabled
# 
#         Counter enabled or return None.
# 
#     """
# 
#     def __init__(self, number=0, enabled=False, sub_counter_enabled=True):
#         self.start = number
#         self.number = self.start
#         self.order_enabled = enabled
#         self.sub_counter_enabled = sub_counter_enabled
# 
#     def get_next(self):
#         if self.order_enabled:
#             self.number += 1
#             return self.number
#         return None
# 
#     @contextmanager
#     def sub_counter(self):
#         if self.sub_counter_enabled:
#             counter = self.number
#             self.number = self.start
#             yield
#             self.number = counter
#             return
#         yield


from jinja2schema.order_number import OrderNumber
# coding: utf-8


def test_get_next_order_number():
    on = OrderNumber(1, enabled=True)
    assert on.get_next() == 2
    on = OrderNumber(1)
    assert on.get_next() is None
    on = OrderNumber(5, enabled=True)
    assert on.get_next() == 6


def test_sub_counter_1():
    on = OrderNumber(1, enabled=True)
    on.get_next()
    assert on.get_next() == 3
    with on.sub_counter():
        assert on.get_next() == 2
    assert on.get_next() == 4


def test_sub_counter_2():

# Path: jinja2schema/order_number.py
# class OrderNumber(object):
#     """A base Order Number class.
# 
#     .. attribute:: number
# 
#         Initial counter value.
# 
#     .. attribute:: enabled
# 
#         Counter enabled or return None.
# 
#     """
# 
#     def __init__(self, number=0, enabled=False, sub_counter_enabled=True):
#         self.start = number
#         self.number = self.start
#         self.order_enabled = enabled
#         self.sub_counter_enabled = sub_counter_enabled
# 
#     def get_next(self):
#         if self.order_enabled:
#             self.number += 1
#             return self.number
#         return None
# 
#     @contextmanager
#     def sub_counter(self):
#         if self.sub_counter_enabled:
#             counter = self.number
#             self.number = self.start
#             yield
#             self.number = counter
#             return
#         yield


# Path: tests/unit_tests/test_order_number.py
from jinja2schema.order_number import OrderNumber

# coding: utf-8


def test_get_next_order_number():
    on = OrderNumber(1, enabled=True)
    assert on.get_next() == 2
    on = OrderNumber(1)
    assert on.get_next() is None
    on = OrderNumber(5, enabled=True)
    assert on.get_next() == 6


def test_sub_counter_1():
    on = OrderNumber(1, enabled=True)
    on.get_next()
    assert on.get_next() == 3
    with on.sub_counter():
        assert on.get_next() == 2
    assert on.get_next() == 4


def test_sub_counter_2():

    on = OrderNumber(12, enabled=True)