File: test_22_mdie.py

package info (click to toggle)
python-pysaml2 2.0.0-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 26,352 kB
  • ctags: 11,612
  • sloc: xml: 219,044; python: 50,122; makefile: 106; sh: 18
file content (50 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
__author__ = 'rolandh'

from saml2 import md
from saml2.mdie import from_dict

from saml2 import saml

from saml2.extension import mdui
from saml2.extension import idpdisc
from saml2.extension import dri
from saml2.extension import mdattr
from saml2.extension import ui
import xmldsig
import xmlenc

ONTS = {
    saml.NAMESPACE: saml,
    mdui.NAMESPACE: mdui,
    mdattr.NAMESPACE: mdattr,
    dri.NAMESPACE: dri,
    ui.NAMESPACE: ui,
    idpdisc.NAMESPACE: idpdisc,
    md.NAMESPACE: md,
    xmldsig.NAMESPACE: xmldsig,
    xmlenc.NAMESPACE: xmlenc
}


def _eq(l1, l2):
    return set(l1) == set(l2)


def _class(cls):
    return "%s&%s" % (cls.c_namespace, cls.c_tag)


def test_construct_contact():
    c = from_dict({
        "__class__": _class(md.ContactPerson),
        "given_name": {"text": "Roland", "__class__": _class(md.GivenName)},
        "sur_name": {"text": "Hedberg", "__class__": _class(md.SurName)},
        "email_address": [{"text":"roland@catalogix.se",
                          "__class__": _class(md.EmailAddress)}],
    }, ONTS)

    print c
    assert c.given_name.text == "Roland"
    assert c.sur_name.text == "Hedberg"
    assert c.email_address[0].text == "roland@catalogix.se"
    assert _eq(c.keyswv(), ["given_name", "sur_name", "email_address"])