Example #1
0
    def test_get_or_create_item(self):
        """
        Test that catalog.models.get_or_create_item works as expected.
        """
        item, created = get_or_create_item(self.client, self.path, self.type)

        self.assertEqual(created, True)
        self.assertEqual(item.path, self.path)
        self.assertEqual(item.type, self.type)
        self.assertEqual(item.client.pk, self.client.pk)
        self.assertEqual(item.client.hostname, self.client.hostname)
Example #2
0
    def setUp(self):
        """
        Create a test user, and an Item to retrieve with the browse_route view.
        """
        User.objects.create_user('test', '*****@*****.**', 'test')

        self.client_obj = Client.objects.create(hostname='test', secret_key='')
        self.item, _ = get_or_create_item(self.client_obj, '/test/item', 'f')
        self.version = Version.objects.create(id=str(uuid.uuid4()),
                                              item=self.item, mtime=123,
                                              size=456)
Example #3
0
    def setUp(self):
        """
        Create a test user, item and version, then put a file into the storage
        system for that version.
        """
        User.objects.create_user('test', '*****@*****.**', 'test')

        self.client_obj = Client.objects.create(hostname='test', secret_key='')
        self.item, _ = get_or_create_item(self.client_obj, self.RESTORE_PATH, 'f')
        self.version = Version.objects.create(id=str(uuid.uuid4()),
                                              item=self.item, mtime=123,
                                              size=456)
Example #4
0
    def setUp(self):
        """
        Create a test user, item and version, then put a file into the storage
        system for that version.
        """
        User.objects.create_user('test', '*****@*****.**', 'test')

        self.client_obj = Client.objects.create(hostname='test', secret_key='')
        self.item, _ = get_or_create_item(self.client_obj, '/test/item', 'f')
        self.version = Version.objects.create(id=str(uuid.uuid4()),
                                              item=self.item, mtime=123,
                                              size=456)

        self.storage = Storage(settings.BACKTRAC_BACKUP_ROOT)

        _, fd = self.storage.put(self.client_obj.hostname, self.item.path,
                                 self.version.id)
        fd.write(self.FILE_CONTENTS)
        fd.close()
Example #5
0
    def setUp(self):
        """
        Create an Item and a chain of versions to test the resolve_original()
        method on.
        """
        import uuid

        self.client = Client.objects.create(hostname='test', secret_key='')
        self.item, _ = get_or_create_item(self.client, '/test/item', 'f')

        self.versions = []
        self.original = Version.objects.create(id=str(uuid.uuid4()),
                                               item=self.item, mtime=123,
                                               size=456)
        v = self.original
        for i in range(5):
            v = Version.objects.create(id=str(uuid.uuid4()), item=self.item,
                                       mtime=123, size=456,
                                       restored_from=v)
            self.versions.append(v)