示例#1
0
 def test_auto_position_first(self, m_gai):
     """Set position to 1 if no other instances exist."""
     m_gai.return_value = []
     p1 = Index()
     # Since Index is not a declarative model, but a mixin that
     # adds a column to models, p1.position needs to be set to None before
     # using auto_position to prevent a TypeError from being raised due to
     # attempting to interpret an unbound column as a boolean.
     p1.position = None
     p1.auto_position()
     assert p1.position == 1
示例#2
0
 def test_auto_position_with_others(self, m_gai):
     p1 = Index()
     p1.position = 1
     p2 = Index()
     p2.position = 2
     p3 = Index()
     p3.position = 3
     m_gai.return_value = [p1, p2, p3]
     p4 = Index()
     p4.position = None
     p4.auto_position()
     assert p4.position == 4