+
+
+class TestCERSetOrdering(TestCase):
+ def test_vectors(self):
+ """Taken from X.690-201508
+ """
+ class B(Choice):
+ schema = (
+ ("c", Integer(impl=tag_ctxp(2))),
+ ("d", Integer(impl=tag_ctxp(4))),
+ )
+
+ class F(Choice):
+ schema = (
+ ("g", Integer(impl=tag_ctxp(5))),
+ ("h", Integer(impl=tag_ctxp(6))),
+ )
+
+ class I(Choice):
+ schema = (
+ ("j", Integer(impl=tag_ctxp(0))),
+ )
+
+ class E(Choice):
+ schema = (
+ ("f", F()),
+ ("i", I()),
+ )
+
+ class A(Set):
+ schema = (
+ ("a", Integer(impl=tag_ctxp(3))),
+ ("b", B(expl=tag_ctxc(1))),
+ ("e", E()),
+ )
+
+ a = A((
+ ("a", Integer(123)),
+ ("b", B(("d", Integer(234)))),
+ ("e", E(("f", F(("g", Integer(345)))))),
+ ))
+ order = sorted(a._values_for_encoding(), key=attrgetter("tag_order_cer"))
+ self.assertSequenceEqual(
+ [i.__class__.__name__ for i in order],
+ ("E", "B", "Integer"),
+ )