Ejemplo n.º 1
0
    def test_bootstrap_picks_up_user(self):
        user = self.obj_factory.make_user()

        TransactionLog.bootstrap(user)

        txlog = get_filesync_store().find(TransactionLog, op_type=TransactionLog.OP_USER_CREATED).one()
        self.assertTxLogDetailsMatchesUserDetails(user, txlog)
Ejemplo n.º 2
0
    def test_bootstrap_picks_up_user(self):
        user = self.obj_factory.make_user()

        TransactionLog.bootstrap(user)

        txlog = get_shard_store(user.shard_id).find(
            TransactionLog, op_type=TransactionLog.OP_USER_CREATED).one()
        self.assertTxLogDetailsMatchesUserDetails(user, txlog)
Ejemplo n.º 3
0
    def test_bootstrap_picks_up_only_live_files(self):
        user = self.obj_factory.make_user()
        photos = self._create_files_for_user(user, u'image/jpeg')
        # Even though all files in this second UDF are dead, the UDF itself is
        # alive so we will have a txlog for it.
        self._create_files_for_user(user, u'image/jpeg', status=u'Dead')

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles(photos)
Ejemplo n.º 4
0
    def test_bootstrap_picks_up_only_live_files(self):
        user = self.obj_factory.make_user()
        photos = self._create_files_for_user(user, u'image/jpeg')
        # Even though all files in this second UDF are dead, the UDF itself is
        # alive so we will have a txlog for it.
        self._create_files_for_user(user, u'image/jpeg', status=u'Dead')

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles(photos)
Ejemplo n.º 5
0
    def test_bootstrap_picks_up_only_files_owned_by_the_given_user(self):
        user = self.obj_factory.make_user(user_id=1)
        photos = self._create_files_for_user(user, "image/jpeg")
        # These files do not belong to the user we're bootstrapping now, so
        # they won't show up on the TXLog.
        self._create_files_for_user(self.obj_factory.make_user(user_id=2), "image/jpeg")

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles(photos)
Ejemplo n.º 6
0
    def test_bootstrap_picks_up_shares(self):
        user = self.obj_factory.make_user()
        directory = self.obj_factory.make_directory(user)
        share = self.obj_factory.make_share(directory)
        self.store.commit()

        TransactionLog.bootstrap(user)

        txlog = get_filesync_store().find(TransactionLog, op_type=TransactionLog.OP_SHARE_ACCEPTED).one()
        expected_attrs = self._get_dict_with_txlog_attrs_from_share(share, directory, TransactionLog.OP_SHARE_ACCEPTED)
        self.assert_txlog_correct(txlog, expected_attrs)
Ejemplo n.º 7
0
    def test_bootstrap_picks_up_only_live_udfs(self):
        user = self.obj_factory.make_user()
        with txlog_disabled():
            root_udf = UserVolume.get_root(self.sstore, user.id)
            live_udf = self.obj_factory.make_udf(user=user)
            live_udf2 = self.obj_factory.make_udf(user=user)
            self.obj_factory.make_udf(user=user, status=STATUS_DEAD)

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpUDFs([root_udf, live_udf, live_udf2])
Ejemplo n.º 8
0
    def test_bootstrap_picks_up_public_folders(self):
        with txlog_disabled():
            user = self.obj_factory.make_user()
            public_dir = self.obj_factory.make_directory(user, public=True)
            self.obj_factory.make_directory(user)
        public_url = get_public_file_url(public_dir)
        self.assertIsNotNone(public_url)

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFolders([public_dir])
Ejemplo n.º 9
0
    def test_bootstrap_picks_up_only_live_udfs(self):
        user = self.obj_factory.make_user()
        with txlog_disabled():
            root_udf = UserVolume.get_root(self.sstore, user.id)
            live_udf = self.obj_factory.make_udf(user=user)
            live_udf2 = self.obj_factory.make_udf(user=user)
            self.obj_factory.make_udf(user=user, status=STATUS_DEAD)

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpUDFs([root_udf, live_udf, live_udf2])
Ejemplo n.º 10
0
    def test_bootstrap_picks_up_public_folders(self):
        with txlog_disabled():
            user = self.obj_factory.make_user()
            public_dir = self.obj_factory.make_directory(user, public=True)
            self.obj_factory.make_directory(user)
        public_url = get_public_file_url(public_dir)
        self.assertIsNotNone(public_url)

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFolders([public_dir])
Ejemplo n.º 11
0
    def test_bootstrap_picks_up_only_files_owned_by_the_given_user(self):
        user = self.obj_factory.make_user(user_id=1)
        photos = self._create_files_for_user(user, u'image/jpeg')
        # These files do not belong to the user we're bootstrapping now, so
        # they won't show up on the TXLog.
        self._create_files_for_user(self.obj_factory.make_user(user_id=2),
                                    u'image/jpeg')

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles(photos)
Ejemplo n.º 12
0
    def test_bootstrap_picks_up_only_folders_in_live_udfs(self):
        user = self.obj_factory.make_user()
        root_udf = UserVolume.get_root(self.store, user.id)
        folder_in_root = self.obj_factory.make_directory(user, root_udf.root_node, "folder1", public=True)
        dead_udf = self.obj_factory.make_udf(user=user)
        self.obj_factory.make_directory(user, dead_udf.root_node, "folder2", public=True)
        dead_udf.delete()
        self.clear_txlogs()

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFolders([folder_in_root])
Ejemplo n.º 13
0
    def test_bootstrap_picks_up_only_files_in_live_udfs(self):
        user = self.obj_factory.make_user()
        root_udf = UserVolume.get_root(self.store, user.id)
        photo_in_root = self.obj_factory.make_file(user, root_udf.root_node, "foo.jpg", "image/jpeg")
        dead_udf = self.obj_factory.make_udf(user=user)
        self.obj_factory.make_file(user, dead_udf.root_node, "foo-in-dead-udf.jpg", "image/jpeg")
        dead_udf.delete()
        self.clear_txlogs()

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles([photo_in_root])
Ejemplo n.º 14
0
    def test_bootstrap_picks_up_shares(self):
        user = self.obj_factory.make_user()
        directory = self.obj_factory.make_directory(user)
        share = self.obj_factory.make_share(directory)
        self.sstore.commit()

        TransactionLog.bootstrap(user)

        txlog = get_shard_store(user.shard_id).find(
            TransactionLog, op_type=TransactionLog.OP_SHARE_ACCEPTED).one()
        expected_attrs = self._get_dict_with_txlog_attrs_from_share(
            share, directory, TransactionLog.OP_SHARE_ACCEPTED)
        self.assert_txlog_correct(txlog, expected_attrs)
Ejemplo n.º 15
0
    def test_bootstrap_picks_up_only_files_in_live_udfs(self):
        user = self.obj_factory.make_user()
        with txlog_disabled():
            root_udf = UserVolume.get_root(self.sstore, user.id)
            photo_in_root = self.obj_factory.make_file(
                user, root_udf.root_node, u'foo.jpg', u'image/jpeg')
            dead_udf = self.obj_factory.make_udf(user=user)
            self.obj_factory.make_file(
                user, dead_udf.root_node, u'foo-in-dead-udf.jpg',
                u'image/jpeg')
            dead_udf.delete()

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles([photo_in_root])
Ejemplo n.º 16
0
    def test_bootstrap_picks_up_only_folders_in_live_udfs(self):
        user = self.obj_factory.make_user()
        with txlog_disabled():
            root_udf = UserVolume.get_root(self.sstore, user.id)
            folder_in_root = self.obj_factory.make_directory(
                user, root_udf.root_node, u'folder1', public=True)
            dead_udf = self.obj_factory.make_udf(user=user)
            self.obj_factory.make_directory(user,
                                            dead_udf.root_node,
                                            u'folder2',
                                            public=True)
            dead_udf.delete()

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFolders([folder_in_root])
Ejemplo n.º 17
0
    def test_bootstrap_picks_up_only_files_in_live_udfs(self):
        user = self.obj_factory.make_user()
        with txlog_disabled():
            root_udf = UserVolume.get_root(self.sstore, user.id)
            photo_in_root = self.obj_factory.make_file(user,
                                                       root_udf.root_node,
                                                       u'foo.jpg',
                                                       u'image/jpeg')
            dead_udf = self.obj_factory.make_udf(user=user)
            self.obj_factory.make_file(user, dead_udf.root_node,
                                       u'foo-in-dead-udf.jpg', u'image/jpeg')
            dead_udf.delete()

        TransactionLog.bootstrap(user)

        self.assertBootstrappingPickedUpFiles([photo_in_root])