コード例 #1
0
 def test_roundtrip_from_key(self, family, block_type):
     key = BlockTypeKeyV1(family, block_type)
     serialized = text_type(key)
     deserialized = BlockTypeKey.from_string(serialized)
     self.assertEqual(key, deserialized)
コード例 #2
0
 def test_parse_deprecated_type(self, key):
     block_type = BlockTypeKey.from_string(key)
     self.assertEqual(key, block_type.block_type)
     self.assertEqual('xblock.v1', block_type.block_family)
コード例 #3
0
 def test_roundtrip_from_string(self, key):
     block_type = BlockTypeKey.from_string(key)
     serialized = text_type(block_type)
     self.assertEqual(key, serialized)
コード例 #4
0
ファイル: block_types.py プロジェクト: timmc-edx/opaque-keys
        Return an instance of `cls` parsed from its deprecated `serialized` form.

        This will be called only if :meth:`OpaqueKey.from_string` is unable to
        parse a key out of `serialized`, and only if `set_deprecated_fallback` has
        been called to register a fallback class.

        Args:
            cls: The :class:`OpaqueKey` subclass.
            serialized (unicode): A serialized :class:`OpaqueKey`, with namespace already removed.

        Raises:
            InvalidKeyError: Should be raised if `serialized` is not a valid serialized key
                understood by `cls`.
        """
        return cls(XBLOCK_V1, serialized)

    def _to_deprecated_string(self):
        """
        Return a deprecated serialization of `self`.

        This will be called only if `set_deprecated_fallback` has
        been called to register a fallback class, and the key being
        serialized has the attribute `deprecated=True`.

        This serialization should not include the namespace prefix.
        """
        return self.block_type


BlockTypeKey.set_deprecated_fallback(BlockTypeKeyV1)
コード例 #5
0
ファイル: test_block_types.py プロジェクト: edx/opaque-keys
 def test_deprecated_roundtrip(self, key):
     block_type = BlockTypeKey.from_string(key)
     serialized = str(block_type)
     self.assertEqual(key, serialized)
コード例 #6
0
 def test_roundtrip_from_key(self, family, block_type):
     key = BlockTypeKeyV1(family, block_type)
     serialized = unicode(key)
     deserialized = BlockTypeKey.from_string(serialized)
     self.assertEqual(key, deserialized)
コード例 #7
0
 def test_roundtrip_from_string(self, key):
     block_type = BlockTypeKey.from_string(key)
     serialized = unicode(block_type)
     self.assertEqual(key, serialized)
コード例 #8
0
 def test_parse_deprecated_type(self, key):
     block_type = BlockTypeKey.from_string(key)
     self.assertEqual(key, block_type.block_type)
     self.assertEqual('xblock.v1', block_type.block_family)
コード例 #9
0
ファイル: block_types.py プロジェクト: GbalsaC/bitnamiP
        """
        Return an instance of `cls` parsed from its deprecated `serialized` form.

        This will be called only if :meth:`OpaqueKey.from_string` is unable to
        parse a key out of `serialized`, and only if `set_deprecated_fallback` has
        been called to register a fallback class.

        Args:
            cls: The :class:`OpaqueKey` subclass.
            serialized (unicode): A serialized :class:`OpaqueKey`, with namespace already removed.

        Raises:
            InvalidKeyError: Should be raised if `serialized` is not a valid serialized key
                understood by `cls`.
        """
        return cls(XBLOCK_V1, serialized)

    def _to_deprecated_string(self):
        """
        Return a deprecated serialization of `self`.

        This will be called only if `set_deprecated_fallback` has
        been called to register a fallback class, and the key being
        serialized has the attribute `deprecated=True`.

        This serialization should not include the namespace prefix.
        """
        return self.block_type

BlockTypeKey.set_deprecated_fallback(BlockTypeKeyV1)
コード例 #10
0
ファイル: test_block_types.py プロジェクト: edx/opaque-keys
 def test_deprecated_roundtrip(self, key):
     block_type = BlockTypeKey.from_string(key)
     serialized = text_type(block_type)
     self.assertEqual(key, serialized)