本文整理匯總了Python中Products.CMFDiffTool.interfaces.IDifference類的典型用法代碼示例。如果您正苦於以下問題:Python IDifference類的具體用法?Python IDifference怎麽用?Python IDifference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了IDifference類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_should_diff
def test_should_diff(self):
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID,
'obj1',
title=u'Object 1',
description=u'Desc 1',
text=u'Text 1'
)
obj1 = self.portal['obj1']
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID,
'obj2',
title=u'Object 2',
text=u'Text 2'
)
obj2 = self.portal['obj2']
diffs = DexterityCompoundDiff(obj1, obj2, 'any')
for d in diffs:
self.assertTrue(IDifference.providedBy(d))
self.assertFalse(d.field in EXCLUDED_FIELDS)
if d.field in ['title', 'description', 'text']:
self.assertFalse(
d.same, 'Field %s should be different.' % d.field)
else:
self.assertTrue(d.same, 'Field %s should be equal.' % d.field)
示例2: test_inline_diff_same
def test_inline_diff_same(self):
value = RichTextValue(u'foo')
diff = CMFDTHtmlDiff(DummyType(value), DummyType(value), 'body')
inline_diff = diff.inline_diff()
self.assertTrue(IDifference.providedBy(diff))
self.assertEqual(diff.same, True)
self.assertEqual(inline_diff, u'foo ')
示例3: test_should_detect_same_data_and_filename
def test_should_detect_same_data_and_filename(self):
setRoles(self.portal, TEST_USER_ID, ["Manager"])
self.portal.invokeFactory(TEST_CONTENT_TYPE_ID, "obj1", file=NamedFile(data="contents", filename=u"f.txt"))
obj1 = self.portal["obj1"]
self.portal.invokeFactory(TEST_CONTENT_TYPE_ID, "obj2", file=NamedFile(data="contents", filename=u"f.txt"))
obj2 = self.portal["obj2"]
diff = DexterityBinaryDiff(obj1, obj2, "file")
self.assertTrue(IDifference.providedBy(diff))
self.assertTrue(diff.same)
示例4: test_inline_diff_different
def test_inline_diff_different(self):
old_value = RichTextValue(u'foo')
new_value = RichTextValue(u'foo bar')
diff = CMFDTHtmlDiff(
DummyType(old_value), DummyType(new_value), 'body')
inline_diff = diff.inline_diff()
self.assertTrue(IDifference.providedBy(diff))
self.assertEqual(diff.same, False)
self.assertEqual(inline_diff, u'foo <span class="insert">bar </span> ')
示例5: _test_diff_bool
def _test_diff_bool(self, b1, b2, same):
diff = BoolDiff(DummyType(b1), DummyType(b2), 'bool_field')
self.assertTrue(IDifference.providedBy(diff))
self.assertEqual(diff.same, same)
inline_diff = diff.inline_diff()
if same:
self.assertFalse(inline_diff)
else:
self.assertTrue(
('True' in inline_diff) or ('False' in inline_diff))
示例6: _test_diff_date
def _test_diff_date(self, d1, d2, same):
diff = AsTextDiff(DateDummyType(d1), DateDummyType(d2), 'date')
self.assertTrue(IDifference.providedBy(diff))
self.assertEqual(diff.same, same)
inline_diff = diff.inline_diff()
if same:
self.assertFalse(inline_diff)
else:
self.assertTrue(inline_diff)
if d1 is not None:
self.assertTrue(str(d1) in inline_diff)
if d2 is not None:
self.assertTrue(str(d2) in inline_diff)
示例7: _test_diff_choice
def _test_diff_choice(self, value1, value2, same):
self.obj1.choice = value1
self.obj2.choice = value2
diff = ChoiceDiff(self.obj1, self.obj2, "choice")
self.assertTrue(IDifference.providedBy(diff))
self.assertEqual(diff.same, same)
inline_diff = diff.inline_diff()
if same:
self.assertFalse(inline_diff)
else:
if value1 is not None:
self.assertTrue(title_or_value(testing.VOCABULARY, value1) in inline_diff)
if value2 is not None:
self.assertTrue(title_or_value(testing.VOCABULARY, value2) in inline_diff)
示例8: test_should_diff
def test_should_diff(self):
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID, "obj1", title=u"Object 1", description=u"Desc 1", text=u"Text 1"
)
obj1 = self.portal["obj1"]
self.portal.invokeFactory(testing.TEST_CONTENT_TYPE_ID, "obj2", title=u"Object 2", text=u"Text 2")
obj2 = self.portal["obj2"]
diffs = DexterityCompoundDiff(obj1, obj2, "any")
for d in diffs:
self.assertTrue(IDifference.providedBy(d))
self.assertFalse(d.field in EXCLUDED_FIELDS)
if d.field in ["title", "description", "text"]:
self.assertFalse(d.same, "Field %s should be different." % d.field)
else:
self.assertTrue(d.same, "Field %s should be equal." % d.field)
示例9: test_should_detect_same_data_and_filename
def test_should_detect_same_data_and_filename(self):
self.loginAsPortalOwner()
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID,
'obj1',
file=NamedFile(data='contents', filename=u'f.txt')
)
obj1 = self.portal['obj1']
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID,
'obj2',
file=NamedFile(data='contents', filename=u'f.txt')
)
obj2 = self.portal['obj2']
diff = namedfile.NamedFileBinaryDiff(obj1, obj2, 'file')
self.assertTrue(IDifference.providedBy(diff))
self.assertTrue(diff.same)
示例10: test_should_detect_same_data_and_filename
def test_should_detect_same_data_and_filename(self):
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory(
TEST_CONTENT_TYPE_ID,
'obj1',
file=NamedFile(data='contents', filename=u'f.txt')
)
obj1 = self.portal['obj1']
self.portal.invokeFactory(
TEST_CONTENT_TYPE_ID,
'obj2',
file=NamedFile(data='contents', filename=u'f.txt')
)
obj2 = self.portal['obj2']
diff = DexterityBinaryDiff(obj1, obj2, 'file')
self.assertTrue(IDifference.providedBy(diff))
self.assertTrue(diff.same)
示例11: test_should_detect_different_data
def test_should_detect_different_data(self):
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID,
'obj1',
file=NamedFile(data='contents', filename=u'f.txt'),
)
obj1 = self.portal['obj1']
self.portal.invokeFactory(
testing.TEST_CONTENT_TYPE_ID,
'obj2',
file=NamedFile(data='different contents', filename=u'f.txt'),
)
obj2 = self.portal['obj2']
diff = namedfile.NamedFileBinaryDiff(obj1, obj2, 'file')
self.assertTrue(IDifference.providedBy(diff))
self.assertFalse(diff.same)
示例12: testInterface
def testInterface(self):
"""Ensure that tool instances implement the portal_diff interface"""
from Products.CMFDiffTool.interfaces import IDifference
self.failUnless(IDifference.implementedBy(TextDiff))
示例13: _test_diff_files
def _test_diff_files(self, files1, files2, same):
diff = DexterityFileListDiff(DummyType(files1), DummyType(files2), 'files')
self.assertTrue(IDifference.providedBy(diff))
self.assertEqual(diff.same, same)
self.assertNotEqual(bool(diff.inline_diff()), same)
示例14: testInterface
def testInterface(self):
"""Ensure that tool instances implement the portal_diff interface"""
self.assertTrue(IDifference.implementedBy(ListDiff))