Beispiel #1
0
 def test_should_wrap_bare_restraint_in_group(self):
     rest = [restraints.SelectableRestraint()]
     with mock.patch("meld.system.restraints.RestraintGroup.__init__",
                     spec=True) as group_init:
         group_init.return_value = None
         restraints.SelectivelyActiveCollection(rest, 1)
         self.assertEqual(group_init.call_count, 1)
Beispiel #2
0
 def test_should_not_wrap_a_group_in_a_group(self):
     rest = [restraints.SelectableRestraint()]
     grps = [restraints.RestraintGroup(rest, 1)]
     with mock.patch("meld.system.restraints.RestraintGroup.__init__",
                     spec=True) as group_init:
         restraints.SelectivelyActiveCollection(grps, 1)
         self.assertEqual(group_init.call_count, 0)
Beispiel #3
0
 def test_can_add_two_restraints(self):
     rest = [
         restraints.SelectableRestraint(),
         restraints.SelectableRestraint()
     ]
     coll = restraints.SelectivelyActiveCollection(rest, 1)
     self.assertEqual(len(coll.groups), 2)
Beispiel #4
0
 def test_num_active_should_be_set(self):
     rest = [restraints.SelectableRestraint()]
     coll = restraints.SelectivelyActiveCollection(rest, 1)
     self.assertEqual(coll.num_active, 1)
Beispiel #5
0
 def test_num_active_greater_than_num_restraints_should_raise(self):
     rest = [restraints.SelectableRestraint()]
     with self.assertRaises(RuntimeError):
         restraints.SelectivelyActiveCollection(rest, 2)
Beispiel #6
0
 def test_negative_num_active_should_raise(self):
     rest = [restraints.SelectableRestraint()]
     with self.assertRaises(RuntimeError):
         restraints.SelectivelyActiveCollection(rest, -1)
Beispiel #7
0
 def test_empty_restraint_list_should_raise(self):
     with self.assertRaises(RuntimeError):
         restraints.SelectivelyActiveCollection([], 0)
Beispiel #8
0
 def test_adding_non_selectable_restraint_should_raise(self):
     rest = [restraints.NonSelectableRestraint()]
     with self.assertRaises(RuntimeError):
         restraints.SelectivelyActiveCollection(rest, 1)
Beispiel #9
0
 def test_restraint_should_be_present_after_adding(self):
     rest = [restraints.SelectableRestraint()]
     coll = restraints.SelectivelyActiveCollection(rest, 1)
     self.assertEqual(len(coll.groups), 1)