@@ -1614,8 +1614,11 @@ def setUp(self):
16141614 self .partner2 = CountryFactory .create (name = "partner2" , iso3 = "AAA" , iso = "AA" )
16151615
16161616 self .user = UserFactory .create ()
1617+ self .url = "/api/v2/pdf-export/"
16171618
1618- self .eap_registration = EAPRegistrationFactory .create (
1619+ @mock .patch ("api.serializers.generate_url.delay" )
1620+ def test_simplified_eap_export (self , mock_generate_url ):
1621+ eap_registration = EAPRegistrationFactory .create (
16191622 eap_type = EAPType .SIMPLIFIED_EAP ,
16201623 country = self .country ,
16211624 national_society = self .national_society ,
@@ -1624,13 +1627,8 @@ def setUp(self):
16241627 created_by = self .user ,
16251628 modified_by = self .user ,
16261629 )
1627-
1628- self .url = "/api/v2/pdf-export/"
1629-
1630- @mock .patch ("api.serializers.generate_url.delay" )
1631- def test_simplified_eap_export (self , mock_generate_url ):
1632- self .simplified_eap = SimplifiedEAPFactory .create (
1633- eap_registration = self .eap_registration ,
1630+ simplified_eap = SimplifiedEAPFactory .create (
1631+ eap_registration = eap_registration ,
16341632 created_by = self .user ,
16351633 modified_by = self .user ,
16361634 national_society_contact_title = "NS Title Example" ,
@@ -1639,9 +1637,12 @@ def test_simplified_eap_export(self, mock_generate_url):
16391637 modified_by = self .user ,
16401638 ),
16411639 )
1640+ eap_registration .latest_simplified_eap = simplified_eap
1641+ eap_registration .save ()
1642+
16421643 data = {
16431644 "export_type" : Export .ExportType .SIMPLIFIED_EAP ,
1644- "export_id" : self . eap_registration .id ,
1645+ "export_id" : eap_registration .id ,
16451646 "is_pga" : False ,
16461647 }
16471648
@@ -1652,7 +1653,7 @@ def test_simplified_eap_export(self, mock_generate_url):
16521653 self .assert_201 (response )
16531654 self .assertIsNotNone (response .data ["id" ], response .data )
16541655
1655- expected_url = f"{ settings .GO_WEB_INTERNAL_URL } /eap/{ self . eap_registration .id } /{ Export .ExportType .SIMPLIFIED_EAP } /export/"
1656+ expected_url = f"{ settings .GO_WEB_INTERNAL_URL } /eap/{ eap_registration .id } /{ Export .ExportType .SIMPLIFIED_EAP } /export/"
16561657 self .assertEqual (response .data ["url" ], expected_url )
16571658 self .assertEqual (response .data ["status" ], Export .ExportStatus .PENDING )
16581659
@@ -1669,12 +1670,12 @@ def test_simplified_eap_export(self, mock_generate_url):
16691670 # Test Export Snapshot
16701671
16711672 # create a new snapshot
1672- simplfied_eap_snapshot = self . simplified_eap .generate_snapshot ()
1673+ simplfied_eap_snapshot = simplified_eap .generate_snapshot ()
16731674 assert simplfied_eap_snapshot .version == 2 , "Snapshot version should be 2"
16741675
16751676 data = {
16761677 "export_type" : Export .ExportType .SIMPLIFIED_EAP ,
1677- "export_id" : self . eap_registration .id ,
1678+ "export_id" : eap_registration .id ,
16781679 "version" : 2 ,
16791680 }
16801681
@@ -1684,7 +1685,7 @@ def test_simplified_eap_export(self, mock_generate_url):
16841685 self .assertIsNotNone (response .data ["id" ], response .data )
16851686
16861687 expected_url = (
1687- f"{ settings .GO_WEB_INTERNAL_URL } /eap/{ self . eap_registration .id } /{ Export .ExportType .SIMPLIFIED_EAP } /export/?version=2"
1688+ f"{ settings .GO_WEB_INTERNAL_URL } /eap/{ eap_registration .id } /{ Export .ExportType .SIMPLIFIED_EAP } /export/?version=2"
16881689 )
16891690 self .assertEqual (response .data ["url" ], expected_url )
16901691
@@ -1699,7 +1700,7 @@ def test_full_eap_export(self, mock_generate_url):
16991700 modified_by = self .user ,
17001701 )
17011702
1702- FullEAPFactory .create (
1703+ full_eap = FullEAPFactory .create (
17031704 eap_registration = eap_registration ,
17041705 created_by = self .user ,
17051706 modified_by = self .user ,
@@ -1708,6 +1709,10 @@ def test_full_eap_export(self, mock_generate_url):
17081709 modified_by = self .user ,
17091710 ),
17101711 )
1712+
1713+ eap_registration .latest_full_eap = full_eap
1714+ eap_registration .save ()
1715+
17111716 data = {
17121717 "export_type" : Export .ExportType .FULL_EAP ,
17131718 "export_id" : eap_registration .id ,
@@ -1745,7 +1750,7 @@ def test_diff_export_eap(self, mock_generate_url):
17451750 modified_by = self .user ,
17461751 )
17471752
1748- SimplifiedEAPFactory .create (
1753+ simplified_eap = SimplifiedEAPFactory .create (
17491754 eap_registration = eap_registration ,
17501755 created_by = self .user ,
17511756 modified_by = self .user ,
@@ -1755,6 +1760,9 @@ def test_diff_export_eap(self, mock_generate_url):
17551760 ),
17561761 )
17571762
1763+ eap_registration .latest_simplified_eap = simplified_eap
1764+ eap_registration .save ()
1765+
17581766 self .authenticate (self .user )
17591767 data = {
17601768 "export_type" : Export .ExportType .SIMPLIFIED_EAP ,
0 commit comments