Exemplo n.º 1
0
 def test_content_modify(self):
     """check between time 0 and 1, just a content edit"""
     version0 = BlockVersion(self.block, 0)
     version1 = BlockVersion(self.block, 1)
     changes = compare_remote_versions(self.service, version0, version1)
     self.assertEqual(0, len(changes.deleted))
     self.assertEqual(0, len(changes.created))
     self.assertEqual(0, len(changes.renames))
     self.assertEqual(1, len(changes.modified))
     diff = compute_diff(changes, resource_diff_function)
     self.assertEqual((None, "--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n" "-hello\n+hello2"), diff.modified["r1.h"])
Exemplo n.º 2
0
 def test_content_modify(self):
     '''check between time 0 and 1, just a content edit'''
     version0 = BlockVersion(self.block, 0)
     version1 = BlockVersion(self.block, 1)
     changes = compare_remote_versions(self.service, version0, version1)
     self.assertEqual(0, len(changes.deleted))
     self.assertEqual(0, len(changes.created))
     self.assertEqual(0, len(changes.renames))
     self.assertEqual(1, len(changes.modified))
     diff = compute_diff(changes, resource_diff_function)
     self.assertEqual((None, '--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n'
                       '-hello\n+hello2'), diff.modified['r1.h'])
Exemplo n.º 3
0
    def test_cell_modify(self):
        """check between time 1 and 2, a BiiType change"""
        version1 = BlockVersion(self.block, 1)
        version2 = BlockVersion(self.block, 2)
        changes = compare_remote_versions(self.service, version1, version2)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(UNKNOWN, changes.modified["r1.h"].old.cell.type)
        self.assertEqual(CPP, changes.modified["r1.h"].new.cell.type)
Exemplo n.º 4
0
    def test_cell_modify(self):
        '''check between time 1 and 2, a BiiType change'''
        version1 = BlockVersion(self.block, 1)
        version2 = BlockVersion(self.block, 2)
        changes = compare_remote_versions(self.service, version1, version2)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(UNKNOWN, changes.modified['r1.h'].old.cell.type)
        self.assertEqual(CPP, changes.modified['r1.h'].new.cell.type)
Exemplo n.º 5
0
    def test_delete(self):
        """4 => 5 r2.h is deleted"""
        version4 = BlockVersion(self.block, 4)
        version5 = BlockVersion(self.block, 5)
        changes = compare_remote_versions(self.service, version4, version5)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual("--- base\n\n+++ other\n\n@@ -1 +0,0 @@\n\n-bye", diff.deleted["r2.h"].content)
        self.assertIsNotNone(diff.deleted["r2.h"].cell)
Exemplo n.º 6
0
    def test_delete(self):
        '''4 => 5 r2.h is deleted'''
        version4 = BlockVersion(self.block, 4)
        version5 = BlockVersion(self.block, 5)
        changes = compare_remote_versions(self.service, version4, version5)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual('--- base\n\n+++ other\n\n@@ -1 +0,0 @@\n\n-bye',
                         diff.deleted['r2.h'].content)
        self.assertIsNotNone(diff.deleted['r2.h'].cell)
Exemplo n.º 7
0
    def test_resource_created(self):
        """ 3 => 4 cell creation"""
        version3 = BlockVersion(self.block, 3)
        version4 = BlockVersion(self.block, 4)
        changes = compare_remote_versions(self.service, version3, version4)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual("--- base\n\n+++ other\n\n@@ -0,0 +1 @@\n\n+bye", diff.created["r2.h"].content)
        # TODO: Implement and check diff of cell
        self.assertIsNotNone(diff.created["r2.h"].cell)
Exemplo n.º 8
0
    def test_cell_content_modify(self):
        """between time 0 and 2 there is content and biitype change"""
        version0 = BlockVersion(self.block, 0)
        version2 = BlockVersion(self.block, 2)
        changes = compare_remote_versions(self.service, version0, version2)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(UNKNOWN, changes.modified["r1.h"].old.cell.type)
        self.assertEqual(CPP, changes.modified["r1.h"].new.cell.type)
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual("--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n" "-hello\n+hello2", diff.modified["r1.h"].content)
Exemplo n.º 9
0
    def test_resource_created(self):
        ''' 3 => 4 cell creation'''
        version3 = BlockVersion(self.block, 3)
        version4 = BlockVersion(self.block, 4)
        changes = compare_remote_versions(self.service, version3, version4)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual('--- base\n\n+++ other\n\n@@ -0,0 +1 @@\n\n+bye',
                         diff.created['r2.h'].content)
        #TODO: Implement and check diff of cell
        self.assertIsNotNone(diff.created['r2.h'].cell)
Exemplo n.º 10
0
    def test_cell_content_modify(self):
        '''between time 0 and 2 there is content and biitype change'''
        version0 = BlockVersion(self.block, 0)
        version2 = BlockVersion(self.block, 2)
        changes = compare_remote_versions(self.service, version0, version2)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(UNKNOWN, changes.modified['r1.h'].old.cell.type)
        self.assertEqual(CPP, changes.modified['r1.h'].new.cell.type)
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(
            '--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n'
            '-hello\n+hello2', diff.modified['r1.h'].content)
Exemplo n.º 11
0
    def test_rename_changes(self):
        version6 = BlockVersion(self.block, 6)
        version7 = BlockVersion(self.block, 7)
        changes = compare_remote_versions(self.service, version6, version7)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(1, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        self.assertEqual("r4.h", changes.renames["r3.h"])
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(0, len(diff.deleted))
        self.assertEqual(0, len(diff.created))
        self.assertEqual("--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n" "-hello3\n+hello4", diff.modified["r3.h"].content)
        self.assertIsNotNone(diff.modified["r3.h"].cell)
        self.assertEqual("r4.h", diff.renames["r3.h"])
Exemplo n.º 12
0
    def test_rename(self):
        version5 = BlockVersion(self.block, 5)
        version6 = BlockVersion(self.block, 6)
        changes = compare_remote_versions(self.service, version5, version6)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(1, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        self.assertEqual("r3.h", changes.renames["r1.h"])
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(0, len(diff.deleted))
        self.assertEqual(0, len(diff.created))
        self.assertEqual("", diff.modified["r1.h"].content)
        self.assertIsNotNone(diff.modified["r1.h"].cell)
        self.assertEqual("r3.h", diff.renames["r1.h"])
Exemplo n.º 13
0
    def test_rename(self):
        version5 = BlockVersion(self.block, 5)
        version6 = BlockVersion(self.block, 6)
        changes = compare_remote_versions(self.service, version5, version6)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(1, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        self.assertEqual('r3.h', changes.renames['r1.h'])
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(0, len(diff.deleted))
        self.assertEqual(0, len(diff.created))
        self.assertEqual('', diff.modified['r1.h'].content)
        self.assertIsNotNone(diff.modified['r1.h'].cell)
        self.assertEqual('r3.h', diff.renames['r1.h'])
Exemplo n.º 14
0
    def compute_diff(self, base_version, other_version):
        ''' Compare two versions '''
        assert base_version.time is not None
        assert other_version.time is not None
        try:
            self.security.check_read_block(base_version.block)
        except NotInStoreException:
            raise NotFoundException("Block version %s not found!\n" % str(base_version.block))

        try:
            self.security.check_read_block(other_version.block)
        except NotInStoreException:
            raise NotFoundException("Block version %s not found!\n" % str(other_version.block))

        #This biiService is only for published versions
        return compare_remote_versions(self, base_version, other_version)
Exemplo n.º 15
0
    def test_cell_content_modify_single_step(self):
        """ 2=> 3 content modify and biitype change in single step"""
        version2 = BlockVersion(self.block, 2)
        version3 = BlockVersion(self.block, 3)
        changes = compare_remote_versions(self.service, version2, version3)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(CPP, changes.modified["r1.h"].old.cell.type)
        self.assertEqual(UNKNOWN, changes.modified["r1.h"].new.cell.type)
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual("--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n" "-hello2\n+hello3", diff.modified["r1.h"].content)
        # TODO: Implement and check diff of cell
        self.assertIsNotNone(diff.modified["r1.h"].cell)
Exemplo n.º 16
0
    def test_cell_content_modify_single_step(self):
        ''' 2=> 3 content modify and biitype change in single step'''
        version2 = BlockVersion(self.block, 2)
        version3 = BlockVersion(self.block, 3)
        changes = compare_remote_versions(self.service, version2, version3)

        self.assertEqual(0, len(changes.deleted))
        self.assertEqual(0, len(changes.created))
        self.assertEqual(0, len(changes.renames))
        self.assertEqual(1, len(changes.modified))
        self.assertEqual(CPP, changes.modified['r1.h'].old.cell.type)
        self.assertEqual(UNKNOWN, changes.modified['r1.h'].new.cell.type)
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(
            '--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n'
            '-hello2\n+hello3', diff.modified['r1.h'].content)
        #TODO: Implement and check diff of cell
        self.assertIsNotNone(diff.modified['r1.h'].cell)
Exemplo n.º 17
0
    def test_rename_changes(self):
        version6 = BlockVersion(self.block, 6)
        version7 = BlockVersion(self.block, 7)
        changes = compare_remote_versions(self.service, version6, version7)

        self.assertEqual(1, len(changes.deleted))
        self.assertEqual(1, len(changes.created))
        self.assertEqual(1, len(changes.renames))
        self.assertEqual(0, len(changes.modified))
        self.assertEqual('r4.h', changes.renames['r3.h'])
        diff = compute_diff(changes, resource_diff_function)
        self.assertEqual(0, len(diff.deleted))
        self.assertEqual(0, len(diff.created))
        self.assertEqual(
            '--- base\n\n+++ other\n\n@@ -1 +1 @@\n\n'
            '-hello3\n+hello4', diff.modified['r3.h'].content)
        self.assertIsNotNone(diff.modified['r3.h'].cell)
        self.assertEqual('r4.h', diff.renames['r3.h'])