def test_basic(self): """ Verify that it is safe to call any Igor methods right from the start without updating the cache or resetting the database. """ igor = azrael.igor.Igor() assert igor.getConstraints(None).ok assert igor.getConstraints([1, 2]).ok assert igor.uniquePairs().ok
def test_uniquePairs(self, getCon): """ Add- and delete constraints and verify that Igor maintins a consistent list of unique body pairs. """ # Convenience. igor = self.igor # Create the constraints for this test. c1 = getCon('foo', 1, 2) c2 = getCon('foo', 2, 3) c3 = getCon('foo', 3, 4) # There must not be any pairs after a reset. assert igor.reset() == (True, None, None) assert igor.uniquePairs() == (True, None, tuple()) # Adding a constraint must result in one unique pair of IDs *after* # updating the Igor cache. assert igor.addConstraints([c1]) == (True, None, 1) assert igor.uniquePairs() == (True, None, tuple()) assert igor.updateLocalCache() == (True, None, 1) assert igor.uniquePairs().data == ((c1.rb_a, c1.rb_b), ) # Add three more constraints, only two of which are actually new. assert igor.addConstraints([c1, c2, c3]) == (True, None, 2) assert igor.updateLocalCache() == (True, None, 3) # Verify that the set of unique pairs now covers those involved in the # constraints. ref = [(_.rb_a, _.rb_b) for _ in (c1, c2, c3)] assert set(igor.uniquePairs().data) == set(tuple(ref)) # Delete two constraints. assert igor.deleteConstraints([c1, c3]) == (True, None, 2) assert set(igor.uniquePairs().data) == set(tuple(ref)) assert igor.updateLocalCache() == (True, None, 1) assert igor.uniquePairs().data == ((c2.rb_a, c2.rb_b), )
def test_uniquePairs(self, getCon): """ Add- and delete constraints and verify that Igor maintins a consistent list of unique body pairs. """ # Convenience. igor = self.igor # Create the constraints for this test. c1 = getCon('foo', '1', '2') c2 = getCon('foo', '2', '3') c3 = getCon('foo', '3', '4') # There must not be any pairs after a reset. assert igor.uniquePairs() == (True, None, tuple()) # Adding a constraint must result in one unique pair of IDs *after* # updating the Igor cache. assert igor.addConstraints([c1]) == (True, None, [True]) assert igor.uniquePairs() == (True, None, tuple()) assert igor.updateLocalCache() == (True, None, 1) assert igor.uniquePairs().data == ((c1.rb_a, c1.rb_b), ) # Add three more constraints, only two of which are actually new. assert igor.addConstraints([c1, c2, c3]) == (True, None, [False, True, True]) assert igor.updateLocalCache() == (True, None, 3) # Verify that the set of unique pairs now covers those involved in the # constraints. ref = [(_.rb_a, _.rb_b) for _ in (c1, c2, c3)] assert set(igor.uniquePairs().data) == set(tuple(ref)) # Delete two constraints. assert igor.removeConstraints([c1, c3]) == (True, None, 2) assert set(igor.uniquePairs().data) == set(tuple(ref)) assert igor.updateLocalCache() == (True, None, 1) assert igor.uniquePairs().data == ((c2.rb_a, c2.rb_b), )