Example #1
0
 def test_bound_with_attribute(self):
     cstr = BoundaryConstraint('<=', Attribute('hop'))
     cstr2 = BoundaryConstraint.deserialize(cstr.serialize())
     self.assertEqual(cstr, cstr2)
     self.assertEqual(cstr2.boundary.attr, 'hop')
     self.assertEqual(cstr2.operator, '<=')
     self.assertTrue(
         cstr2.check(mock_object(hop=date.today()), 'hip', date.today()))
     # fail, value > maxvalue
     self.assertFalse(
         cstr2.check(mock_object(hop=date.today()), 'hip',
                     date.today() + timedelta(days=1)))
Example #2
0
 def test_interval_with_attribute(self):
     cstr = IntervalBoundConstraint(NOW(), Attribute('hop'))
     cstr2 = IntervalBoundConstraint.deserialize(cstr.serialize())
     self.assertEqual(cstr2.minvalue.offset, None)
     self.assertEqual(cstr2.maxvalue.attr, 'hop')
     self.assertTrue(
         cstr2.check(mock_object(hop=datetime.now() + timedelta(hours=1)),
                     'hip',
                     datetime.now() + timedelta(seconds=2)))
     # fail, value < minvalue
     self.assertFalse(
         cstr2.check(mock_object(hop=datetime.now() + timedelta(hours=1)),
                     'hip',
                     datetime.now() - timedelta(hours=2)))
     # fail, value > maxvalue
     self.assertFalse(
         cstr2.check(mock_object(hop=datetime.now() + timedelta(hours=1)),
                     'hip',
                     datetime.now() + timedelta(hours=2)))
Example #3
0
 def test_mockobject(self):
     obj = mock_object(foo='bar', baz='bam')
     self.assertEqual(obj.foo, 'bar')
     self.assertEqual(obj.baz, 'bam')
                      row=0,
                      col=0,
                      rtype='in_group',
                      peid=geid,
                      role='object',
                      i18nctx='',
                      pform=MOCKPFORM,
                      template=None,
                      req=req).source

    def test_automatic_inline_creation_formview(self):
        with self.admin_access.web_request() as req:
            geid = req.execute('CWGroup X LIMIT 1')[0][0]
            self.view('inline-creation',
                      None,
                      etype='CWUser',
                      rtype='in_group',
                      peid=geid,
                      petype='CWGroup',
                      i18nctx='',
                      role='object',
                      pform=MOCKPFORM,
                      template=None,
                      req=req)


MOCKPFORM = mock_object(form_previous_values={}, form_valerror=None)

if __name__ == '__main__':
    unittest_main()
Example #5
0
 def test_mockobject(self):
     obj = mock_object(foo='bar', baz='bam')
     self.assertEquals(obj.foo, 'bar')
     self.assertEquals(obj.baz, 'bam')
Example #6
0
 def setUp(self):
     super(ResultSetTC, self).setUp()
     self.rset = ResultSet([[12, 'adim'], [13, 'syt']],
                           'Any U,L where U is CWUser, U login L',
                           description=[['CWUser', 'String'], ['Bar', 'String']])
     self.rset.req = mock_object(vreg=self.vreg, repo=self.repo)
Example #7
0
 def test_mockobject(self):
     obj = mock_object(foo="bar", baz="bam")
     self.assertEqual(obj.foo, "bar")
     self.assertEqual(obj.baz, "bam")
Example #8
0
 def setUp(self):
     """ called before each test from this class """
     self.vreg = mock_object(config=config, schema=schema)
     self.o = hook.HooksRegistry(self.vreg)
Example #9
0
 def test_bound_with_unset_attribute(self):
     cstr = BoundaryConstraint('<=', None)
     self.assertTrue(cstr.check(None, 'hip', date.today()))
     cstr = BoundaryConstraint('<=', Attribute('unset_attr'))
     self.assertTrue(
         cstr.check(mock_object(unset_attr=None), 'hip', date.today()))