Projet

Général

Profil

0004-hobo_notify-test-phone-number-provisionning-69838.patch

Paul Marillonnet, 22 novembre 2022 14:55

Télécharger (3,03 ko)

Voir les différences:

Subject: [PATCH 4/5] hobo_notify: test phone number provisionning (#69838)

 tests/test_hobo_notify.py | 41 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
tests/test_hobo_notify.py
515 515
                    'first_name': 'John',
516 516
                    'last_name': 'Doé',
517 517
                    'email': 'john.doe@example.net',
518
                    'phone': '+33123456789',
518 519
                    'zipcode': '13400',
519 520
                    'is_superuser': False,
520 521
                    'is_active': True,
......
540 541
    assert user.form_data is not None
541 542
    assert user.form_data['_email'] == 'john.doe@example.net'
542 543
    assert user.email == 'john.doe@example.net'
544
    assert user.form_data['_phone'] == '+33123456789'
543 545
    assert user.form_data['_first_name'] == 'John'
544 546
    assert user.form_data['_last_name'] == force_str('Doé')
545 547
    assert user.form_data['_zipcode'] == '13400'
......
668 670
        assert User.select()[0].first_name == 'John'
669 671
        assert not User.select()[0].email
670 672

  
673
    # check provisionning an account with no phone works
674
    for no_phone in (None, ''):
675
        User.wipe()
676
        notification = {
677
            '@type': 'provision',
678
            'issuer': 'http://idp.example.net/idp/saml/metadata',
679
            'audience': ['test'],
680
            'objects': {
681
                '@type': 'user',
682
                'data': [
683
                    {
684
                        'uuid': 'a' * 32,
685
                        'first_name': 'John',
686
                        'last_name': 'Doé',
687
                        'email': 'john.doe@example.net',
688
                        'phone': no_phone,
689
                        'zipcode': '13400',
690
                        'is_superuser': False,
691
                        'roles': [
692
                            {
693
                                'uuid': uuid1,
694
                                'name': 'Service petite enfance',
695
                                'description': 'etc.',
696
                            },
697
                            {
698
                                'uuid': uuid2,
699
                                'name': 'Service état civil',
700
                                'description': 'etc.',
701
                            },
702
                        ],
703
                    }
704
                ],
705
            },
706
        }
707
        CmdHoboNotify.process_notification(notification)
708
        assert User.count() == 1
709
        assert User.select()[0].first_name == 'John'
710
        assert not User.select()[0].phone
711

  
671 712

  
672 713
def record_error(exception=None, *args, **kwargs):
673 714
    if exception:
674
-