Exemplo n.º 1
0
 def _get_dict_with_txlog_attrs_from_share(self, share, node, op_type):
     when_last_changed = share.when_last_changed
     extra_data = dict(
         shared_to=share.shared_to, share_id=str(share.id),
         share_name=share.name, access_level=share.access,
         when_shared=get_epoch_secs(share.when_shared),
         when_last_changed=get_epoch_secs(when_last_changed))
     return self._get_dict_with_txlog_attrs_from(
         node, op_type, omit_generation=True,
         extra=dict(extra_data_dict=extra_data))
Exemplo n.º 2
0
 def test__get_extra_data_for_new_node(self):
     """Check that _get_extra_data_for_new_node includes all we need."""
     f = self._make_file()
     f_extra_data = dict(
         size=f.content.size, storage_key=unicode(f.content.storage_key),
         publicfile_id=None, public_uuid=None, content_hash=f.content_hash,
         when_created=get_epoch_secs(f.when_created),
         last_modified=get_epoch_secs(f.when_last_modified),
         kind=f.kind, volume_path=f.volume.path)
     expected = TransactionLog._get_extra_data_for_new_node(
         f, f.volume.path)
     self.assertEqual(expected, f_extra_data)
Exemplo n.º 3
0
 def _get_dict_with_txlog_attrs_from_share(self, share, node, op_type):
     when_last_changed = share.when_last_changed
     extra_data = dict(shared_to=share.shared_to,
                       share_id=str(share.id),
                       share_name=share.name,
                       access_level=share.access,
                       when_shared=get_epoch_secs(share.when_shared),
                       when_last_changed=get_epoch_secs(when_last_changed))
     return self._get_dict_with_txlog_attrs_from(
         node,
         op_type,
         omit_generation=True,
         extra=dict(extra_data_dict=extra_data))
Exemplo n.º 4
0
 def test__get_extra_data_for_new_node(self):
     """Check that _get_extra_data_for_new_node includes all we need."""
     f = self._make_file()
     f_extra_data = dict(size=f.content.size,
                         storage_key=unicode(f.content.storage_key),
                         publicfile_id=None,
                         public_uuid=None,
                         content_hash=f.content_hash,
                         when_created=get_epoch_secs(f.when_created),
                         last_modified=get_epoch_secs(f.when_last_modified),
                         kind=f.kind,
                         volume_path=f.volume.path)
     expected = TransactionLog._get_extra_data_for_new_node(
         f, f.volume.path)
     self.assertEqual(expected, f_extra_data)
Exemplo n.º 5
0
 def _get_dict_with_txlog_attrs_from_udf(self, udf, op_type):
     extra_data = None
     if op_type == TransactionLog.OP_UDF_CREATED:
         when_created = get_epoch_secs(udf.when_created)
         extra_data = dict(when_created=when_created)
     return dict(
         node_id=None, volume_id=udf.id, owner_id=udf.owner_id,
         op_type=op_type, extra_data_dict=extra_data,
         generation=udf.generation, path=udf.path)
Exemplo n.º 6
0
 def _get_dict_with_txlog_attrs_from_udf(self, udf, op_type):
     extra_data = None
     if op_type == TransactionLog.OP_UDF_CREATED:
         when_created = get_epoch_secs(udf.when_created)
         extra_data = dict(when_created=when_created)
     return dict(node_id=None,
                 volume_id=udf.id,
                 owner_id=udf.owner_id,
                 op_type=op_type,
                 extra_data_dict=extra_data,
                 generation=udf.generation,
                 path=udf.path)
Exemplo n.º 7
0
 def assertBootstrappingPickedUpUDFs(self, udfs):
     txlogs = self.sstore.find(
         TransactionLog, op_type=TransactionLog.OP_UDF_CREATED)
     expected = {}
     self.assertEqual(len(udfs), txlogs.count())
     for udf in udfs:
         udf_txlog = txlogs.find(volume_id=udf.id).one()
         when_created = get_epoch_secs(udf.when_created)
         expected = dict(
             node_id=None, volume_id=udf.id, generation=udf.generation,
             path=udf.path, mimetype=None, owner_id=udf.owner_id,
             extra_data_dict=dict(when_created=when_created),
             op_type=TransactionLog.OP_UDF_CREATED)
         self.assert_txlog_correct(udf_txlog, expected)
Exemplo n.º 8
0
 def assertBootstrappingPickedUpUDFs(self, udfs):
     txlogs = self.sstore.find(TransactionLog,
                               op_type=TransactionLog.OP_UDF_CREATED)
     expected = {}
     self.assertEqual(len(udfs), txlogs.count())
     for udf in udfs:
         udf_txlog = txlogs.find(volume_id=udf.id).one()
         when_created = get_epoch_secs(udf.when_created)
         expected = dict(node_id=None,
                         volume_id=udf.id,
                         generation=udf.generation,
                         path=udf.path,
                         mimetype=None,
                         owner_id=udf.owner_id,
                         extra_data_dict=dict(when_created=when_created),
                         op_type=TransactionLog.OP_UDF_CREATED)
         self.assert_txlog_correct(udf_txlog, expected)