コード例 #1
0
    def __init__(self,
                 obj1,
                 obj2,
                 field,
                 id1=None,
                 id2=None,
                 field_name=None,
                 field_label=None,
                 schemata=None):
        FieldDiff.__init__(self, obj1, obj2, field, id1, id2, field_name,
                           field_label, schemata)
        self._vocabulary = None

        # Tries to find a vocabulary. First we need to find an object and
        # the field instance.
        obj = obj1 if (obj1 is not None) else obj2
        field_name = field_name or field
        if obj and field_name and IDexterityContent.providedBy(obj):
            field_instance = get_field_object(obj, field_name)
            if field_instance is not None:
                # Binding the field to an object will construct the vocabulary
                # using a factory if necessary.
                try:
                    self._vocabulary = field_instance.value_type.bind(obj).\
                        vocabulary
                except Exception:
                    pass
コード例 #2
0
ファイル: testFieldDiff.py プロジェクト: dtgit/dtedu
 def testGetLineDiffsDifferent(self):
     """test getLineDiffs() method with different value"""
     a = A()
     b = B()
     fd = FieldDiff(a, b, 'attribute')
     expected = [('replace', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
コード例 #3
0
 def testDiffText(self):
     """Test text diff output with different value"""
     a = A()
     b = B()
     expected = "- value%s+ different value" % linesep
     fd = FieldDiff(a, b, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
コード例 #4
0
 def testGetLineDiffsDifferent(self):
     """test getLineDiffs() method with different value"""
     a = A()
     b = B()
     fd = FieldDiff(a, b, 'attribute')
     expected = [('replace', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
コード例 #5
0
ファイル: testFieldDiff.py プロジェクト: dtgit/dtedu
 def testDiffText(self):
     """Test text diff output with different value"""
     a = A()
     b = B()
     expected = "- value\n+ different value"
     fd = FieldDiff(a, b, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
コード例 #6
0
ファイル: testFieldDiff.py プロジェクト: CGTIC/Plone_SP
 def testSameText(self):
     """Test text diff output with same value"""
     a = A()
     fd = FieldDiff(a, a, 'attribute')
     self.assertEqual(fd.ndiff(), '  value')
     uu = U()
     fd = FieldDiff(uu, uu, 'attribute')
     self.assertEqual(fd.ndiff(), u'  \xfcnicode value')
コード例 #7
0
 def testMethodSame(self):
     """Test method with same value"""
     a = A()
     fd = FieldDiff(a, a, 'method')
     self.assertTrue(fd.same)
     uu = U()
     fd = FieldDiff(uu, uu, 'method')
     self.assertTrue(fd.same)
コード例 #8
0
 def testMethodSame(self):
     """Test method with same value"""
     a = A()
     fd = FieldDiff(a, a, 'method')
     self.failUnless(fd.same)
     uu = U()
     fd = FieldDiff(uu, uu, 'method')
     self.failUnless(fd.same)
コード例 #9
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     fd = FieldDiff(a, a, 'attribute')
     self.failUnless(fd.same)
     uu = U()
     fd = FieldDiff(uu, uu, 'attribute')
     self.failUnless(fd.same)
コード例 #10
0
 def testAttributeSame(self):
     """Test attribute with same value"""
     a = A()
     fd = FieldDiff(a, a, 'attribute')
     self.assertTrue(fd.same)
     uu = U()
     fd = FieldDiff(uu, uu, 'attribute')
     self.assertTrue(fd.same)
コード例 #11
0
 def testAttributeDiff(self):
     """Test attribute with different value"""
     a = A()
     b = B()
     uu = U()
     fd = FieldDiff(a, b, 'attribute')
     self.assertFalse(fd.same)
     fd = FieldDiff(a, uu, 'attribute')
     self.assertFalse(fd.same)
コード例 #12
0
 def testMethodDiff(self):
     """Test method with different value"""
     a = A()
     b = B()
     uu = U()
     fd = FieldDiff(a, b, 'method')
     self.assertFalse(fd.same)
     fd = FieldDiff(a, uu, 'method')
     self.assertFalse(fd.same)
コード例 #13
0
ファイル: testFieldDiff.py プロジェクト: CGTIC/Plone_SP
 def testGetLineDiffsSame(self):
     """test getLineDiffs() method with same value"""
     a = A()
     fd = FieldDiff(a, a, 'attribute')
     expected = [('equal', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
     uu = U()
     fd = FieldDiff(uu, uu, 'attribute')
     expected = [('equal', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
コード例 #14
0
ファイル: testFieldDiff.py プロジェクト: CGTIC/Plone_SP
 def testDiffText(self):
     """Test text diff output with different value"""
     a = A()
     b = B()
     uu = U()
     expected = "- value%s+ different value" % linesep
     fd = FieldDiff(a, b, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
     expected = u"- value%s+ \xfcnicode value" % linesep
     fd = FieldDiff(a, uu, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
コード例 #15
0
    def __init__(self, obj1, obj2, field, id1=None, id2=None, field_name=None,
                 field_label=None, schemata=None):
        FieldDiff.__init__(self, obj1, obj2, field, id1, id2, field_name,
                           field_label, schemata)
        self._vocabulary = None

        # Tries to find a vocabulary. First we need to find an object and
        # the field instance.
        obj = obj1 if (obj1 is not None) else obj2
        field_name = field_name or field
        if obj and field_name and IDexterityContent.providedBy(obj):
            field_instance = get_field_object(obj, field_name)
            if field_instance is not None:
                # Binding the field to an object will construct the vocabulary
                # using a factory if necessary.
                try:
                    self._vocabulary = field_instance.value_type.bind(obj).\
                        vocabulary
                except Exception:
                    pass
コード例 #16
0
 def testSameText(self):
     """Test text diff output with same value"""
     a = A()
     fd = FieldDiff(a, a, 'attribute')
     self.assertEqual(fd.ndiff(), '  value')
     uu = U()
     fd = FieldDiff(uu, uu, 'attribute')
     self.assertEqual(fd.ndiff(), u'  \xfcnicode value')
コード例 #17
0
 def testGetLineDiffsSame(self):
     """test getLineDiffs() method with same value"""
     a = A()
     fd = FieldDiff(a, a, 'attribute')
     expected = [('equal', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
     uu = U()
     fd = FieldDiff(uu, uu, 'attribute')
     expected = [('equal', 0, 1, 0, 1)]
     self.assertEqual(fd.getLineDiffs(), expected)
コード例 #18
0
 def testDiffText(self):
     """Test text diff output with different value"""
     a = A()
     b = B()
     uu = U()
     expected = '- value%s+ different value' % linesep
     fd = FieldDiff(a, b, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
     expected = u'- value%s+ \xfcnicode value' % linesep
     fd = FieldDiff(a, uu, 'attribute')
     self.assertEqual(fd.ndiff(), expected)
コード例 #19
0
 def testAttributeDiff(self):
     """Test attribute with different value"""
     a = A()
     b = B()
     fd = FieldDiff(a, b, 'attribute')
     self.failIf(fd.same)
コード例 #20
0
 def testMethodDiff(self):
     """Test method with different value"""
     a = A()
     b = B()
     fd = FieldDiff(a, b, 'method')
     self.failIf(fd.same)