Projet

Général

Profil

0002-toulouse_maelis-adapt-payloads-on-RL-tests-67326.patch

Nicolas Roche, 18 juillet 2022 01:50

Télécharger (8,8 ko)

Voir les différences:

Subject: [PATCH 2/5] toulouse_maelis: adapt payloads on RL tests (#67326)

 tests/test_toulouse_maelis.py | 130 +++++++++++++---------------------
 1 file changed, 51 insertions(+), 79 deletions(-)
tests/test_toulouse_maelis.py
573 573

  
574 574
@mock.patch('passerelle.utils.Request.get')
575 575
@mock.patch('passerelle.utils.Request.post')
576 576
def test_create_family(mocked_post, mocked_get, con, app):
577 577
    mocked_get.return_value = FAMILY_SERVICE_WSDL
578 578
    mocked_post.return_value = CREATE_FAMILY
579 579
    url = get_endpoint('create-family')
580 580
    params = {
581
        'rl1/adresse': {
582
            'street1': 'Chateau',
583
            'town': 'Paris',
584
            'zipcode': '75014',
585
        },
586
        'rl1': {
587
            'firstname': 'Jhon',
588
            'lastname': 'Doe',
589
            'quality': 'AU',
590
            'dateBirth': '1938-07-26',
591
        },
592 581
        'categorie': 'ACCEUI',
593 582
        'situation': 'C',
583
        'rl1/firstname': 'Jhon',
584
        'rl1/lastname': 'Doe',
585
        'rl1/quality': 'AU',
586
        'rl1/dateBirth': '1938-07-26',
587
        'rl1/adresse/street1': 'Chateau',
588
        'rl1/adresse/town': 'Paris',
589
        'rl1/adresse/zipcode': '75014',
594 590
    }
595 591

  
596 592
    resp = app.post_json(url + '?NameID=local', params=params)
597 593
    assert_sent_payload(mocked_post, 'Q_create_family.xml')
598 594
    assert resp.json['err'] == 0
599 595
    assert resp.json['data'] == {
600 596
        'number': 196545,
601 597
        'password': '394634V2',
......
603 599
        'childErrorList': [],
604 600
    }
605 601
    assert Link.objects.get(resource=con, family_id='196545', name_id='local')
606 602

  
607 603

  
608 604
def test_create_family_already_linked_error(con, app):
609 605
    url = get_endpoint('create-family')
610 606
    params = {
611
        'rl1/adresse': {
612
            'street1': 'Chateau',
613
            'town': 'Paris',
614
            'zipcode': '75014',
615
        },
616
        'rl1': {
617
            'firstname': 'Jhon',
618
            'lastname': 'Doe',
619
            'quality': 'AU',
620
            'dateBirth': '1938-07-26',
621
        },
622 607
        'categorie': 'ACCEUI',
623 608
        'situation': 'C',
609
        'rl1/firstname': 'Jhon',
610
        'rl1/lastname': 'Doe',
611
        'rl1/quality': 'AU',
612
        'rl1/dateBirth': '1938-07-26',
613
        'rl1/adresse/street1': 'Chateau',
614
        'rl1/adresse/town': 'Paris',
615
        'rl1/adresse/zipcode': '75014',
624 616
    }
625 617

  
626 618
    Link.objects.create(resource=con, family_id='1312', name_id='local')
627 619
    resp = app.post_json(url + '?NameID=local', params=params)
628 620
    assert resp.json['err'] == 'already-linked'
629 621
    assert resp.json['err_desc'] == 'User already linked to family'
630 622

  
631 623

  
632 624
@mock.patch('passerelle.utils.Request.get')
633 625
@mock.patch('passerelle.utils.Request.post')
634 626
def test_create_family_maelis_error(mocked_post, mocked_get, con, app):
635 627
    mocked_get.return_value = FAMILY_SERVICE_WSDL
636 628
    mocked_post.return_value = CREATE_FAMILY_ERR
637 629
    url = get_endpoint('create-family')
638 630
    params = {
639
        'rl1/adresse': {
640
            'street1': 'Chateau',
641
            'town': 'Paris',
642
            'zipcode': '75014',
643
        },
644
        'rl1': {
645
            'firstname': 'Jhon',
646
            'lastname': 'Doe',
647
            'quality': 'AU',
648
            'dateBirth': '1938-07-26',
649
        },
650 631
        'categorie': 'ACCEUI',
651 632
        'situation': 'C',
633
        'rl1/firstname': 'Jhon',
634
        'rl1/lastname': 'Doe',
635
        'rl1/quality': 'AU',
636
        'rl1/dateBirth': '1938-07-26',
637
        'rl1/adresse/street1': 'Chateau',
638
        'rl1/adresse/town': 'Paris',
639
        'rl1/adresse/zipcode': '75014',
652 640
    }
653 641

  
654 642
    resp = app.post_json(url + '?NameID=local', params=params)
655 643
    assert resp.json['err'] == 'E54a'
656 644
    assert 'Il existe déjà' in resp.json['err_desc']
657 645

  
658 646

  
659 647
@mock.patch('passerelle.utils.Request.get')
660 648
@mock.patch('passerelle.utils.Request.post')
661 649
def test_update_family(mocked_post, mocked_get, con, app):
662 650
    mocked_get.return_value = FAMILY_SERVICE_WSDL
663 651
    mocked_post.return_value = UPDATE_FAMILY
664 652
    url = get_endpoint('update-family')
665 653
    params = {
666
        'rl1/adresse': {
667
            'street1': 'Chateau',
668
            'town': 'Paris',
669
            'zipcode': '75014',
670
        },
671
        'rl1': {
672
            'firstname': 'Jhon',
673
            'lastname': 'Doe',
674
            'quality': 'AU',
675
            'dateBirth': '1938-07-26',
676
        },
677 654
        'categorie': 'BI',
678 655
        'situation': 'C',
656
        'rl1/firstname': 'Jhon',
657
        'rl1/lastname': 'Doe',
658
        'rl1/quality': 'AU',
659
        'rl1/dateBirth': '1938-07-26',
660
        'rl1/adresse/street1': 'Chateau',
661
        'rl1/adresse/town': 'Paris',
662
        'rl1/adresse/zipcode': '75014',
679 663
    }
680 664

  
681 665
    Link.objects.create(resource=con, family_id='1312', name_id='local')
682 666
    resp = app.post_json(url + '?NameID=local', params=params)
683 667
    assert_sent_payload(mocked_post, 'Q_update_family.xml')
684 668
    assert resp.json['err'] == 0
685 669

  
686 670

  
687 671
def test_update_family_already_not_linked_error(con, app):
688 672
    url = get_endpoint('update-family')
689 673
    params = {
690
        'rl1/adresse': {
691
            'street1': 'Chateau',
692
            'town': 'Paris',
693
            'zipcode': '75014',
694
        },
695
        'rl1': {
696
            'firstname': 'Jhon',
697
            'lastname': 'Doe',
698
            'quality': 'AU',
699
            'dateBirth': '1938-07-26',
700
        },
701
        'categorie': 'ACCEUI',
674
        'categorie': 'BI',
702 675
        'situation': 'C',
676
        'rl1/firstname': 'Jhon',
677
        'rl1/lastname': 'Doe',
678
        'rl1/quality': 'AU',
679
        'rl1/dateBirth': '1938-07-26',
680
        'rl1/adresse/street1': 'Chateau',
681
        'rl1/adresse/town': 'Paris',
682
        'rl1/adresse/zipcode': '75014',
703 683
    }
704 684

  
705 685
    resp = app.post_json(url + '?NameID=local', params=params)
706 686
    assert resp.json['err'] == 'not-linked'
707 687
    assert resp.json['err_desc'] == 'User not linked to family'
708 688

  
709 689

  
710 690
@mock.patch('passerelle.utils.Request.get')
711 691
@mock.patch('passerelle.utils.Request.post')
712 692
def test_update_family_soap_error(mocked_post, mocked_get, con, app):
713 693
    mocked_get.return_value = FAMILY_SERVICE_WSDL
714 694
    mocked_post.return_value = UPDATE_FAMILY_500
715 695
    url = get_endpoint('update-family')
716 696
    params = {
717
        'rl1/adresse': {
718
            'street1': 'Chateau',
719
            'town': 'Paris',
720
            'zipcode': '75014',
721
        },
722
        'rl1': {
723
            'firstname': 'Jhon',
724
            'lastname': 'Doe',
725
            'quality': 'AU',
726
            'dateBirth': '1938-07-26',
727
        },
697
        'nbChild': '100',
728 698
        'categorie': 'BI',
729 699
        'situation': 'C',
730
        'nbChild': '100',
700
        'rl1/firstname': 'Jhon',
701
        'rl1/lastname': 'Doe',
702
        'rl1/quality': 'AU',
703
        'rl1/dateBirth': '1938-07-26',
704
        'rl1/adresse/street1': 'Chateau',
705
        'rl1/adresse/town': 'Paris',
706
        'rl1/adresse/zipcode': '75014',
731 707
    }
732 708

  
733 709
    Link.objects.create(resource=con, family_id='1312', name_id='local')
734 710
    resp = app.post_json(url + '?NameID=local', params=params)
735 711
    assert resp.json['err'] == 'Family-updateFamily-soap:Server'
736 712
    assert 'Une erreur est survenue' in resp.json['err_desc']
737 713

  
738 714

  
739 715
@mock.patch('passerelle.utils.Request.get')
740 716
@mock.patch('passerelle.utils.Request.post')
741 717
def test_update_coordinate(mocked_post, mocked_get, con, app):
742 718
    mocked_get.return_value = FAMILY_SERVICE_WSDL
743 719
    mocked_post.return_value = UPDATE_FAMILY
744 720
    url = get_endpoint('update-coordinate')
745 721
    params = {
746
        'adresse': {
747
            'num': '169',
748
            'numComp': None,
749
            'street1': 'Château',
750
            'street2': None,
751
            'town': 'Paris',
752
            'zipcode': '75014',
753
        }
722
        'adresse/num': '169',
723
        'adresse/numComp': None,
724
        'adresse/street1': 'Château',
725
        'adresse/street2': None,
726
        'adresse/town': 'Paris',
727
        'adresse/zipcode': '75014',
754 728
    }
755 729

  
756 730
    Link.objects.create(resource=con, family_id='1312', name_id='local')
757 731
    resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
758 732
    assert_sent_payload(mocked_post, 'Q_update_coordinate.xml')
759 733
    assert resp.json['err'] == 0
760 734
    assert resp.json['data'] == 'ok'
761 735

  
762 736

  
763 737
def test_update_coordinate_schema_error(con, app):
764 738
    url = get_endpoint('update-coordinate')
765 739
    params = {
766
        'contact': {
767
            'isContactMail': 'true more text',
768
        }
740
        'contact/isContactMail': 'true more text',
769 741
    }
770 742

  
771 743
    resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params, status=400)
772 744
    assert resp.json['err'] == 1
773 745
    assert resp.json['err_desc'] == "'true more text' is not of type 'boolean'"
774
-