示例#1
0
 def test_error1(self):
     model = AbstractModel()
     try:
         model.a = BuildCheck()
         self.fail("Expected ValueError")
     except ValueError:
         pass
示例#2
0
 def test_false(self):
     """Apply a build check that returns false"""
     self.model.action1 = BuildCheck(rule=action1b_fn)
     try:
         self.instance = self.model.create_instance()
         self.fail("expected failure")
     except ValueError:
         pass
示例#3
0
 def test_false(self):
     """Check the value of the parameter"""
     self.model.action2 = BuildCheck(self.model.Z, rule=action2b_fn)
     try:
         self.instance = self.model.create_instance()
         self.fail("expected failure")
     except ValueError:
         pass
示例#4
0
    def test_io(self):
        model = AbstractModel()
        model.c1 = BuildCheck(rule=lambda M: True)
        model.A = Set(initialize=[1,2,3])
        model.c2 = BuildCheck(model.A, rule=lambda M,i: True)
        instance = model.create_instance()
        #
        buf = StringIO()
        instance.pprint(ostream=buf)
        self.assertEqual(buf.getvalue(),"""1 Set Declarations
    A : Size=1, Index=None, Ordered=Insertion
        Key  : Dimen : Domain : Size : Members
        None :     1 :    Any :    3 : {1, 2, 3}

2 BuildCheck Declarations
    c1 : 
    c2 : 

3 Declarations: c1 A c2
""")
示例#5
0
 def test_true(self):
     """Apply a build check that returns true"""
     self.model.action1 = BuildCheck(rule=action1a_fn)
     self.instance = self.model.create_instance()
     tmp = value(self.instance.A)
     self.assertEqual(tmp, 3.3)
示例#6
0
 def test_true(self):
     """Check the value of the parameter"""
     self.model.action2 = BuildCheck(self.model.Z, rule=action2a_fn)
     self.instance = self.model.create_instance()