diff --git a/deployments/snapshots/snap_tests.py b/deployments/snapshots/snap_tests.py index efb4e9f1b..ad4b543a1 100644 --- a/deployments/snapshots/snap_tests.py +++ b/deployments/snapshots/snap_tests.py @@ -113,14 +113,14 @@ { "actual_expenditure": 0, "annual_splits": [], - "budget_amount": 6440000, + "budget_amount": 100000, "description": "", "document": None, - "dtype": 3, + "dtype": 1, "dtype_detail": { - "id": 3, - "name": "disaster-type-MSVGtSJuTVJOnmnNTsRwRiTPlGISOuThWwJELKQTARVIsBZaHg", - "summary": "byjdQdmrWYksRqjdSYsnWIcwCgNRVJoVPJypGYYZSsSQdyyAYRuJdaVqmNXCoOTTPxWLIVMmXUmsClRellVGhycBrJqikLqavDTjcjuMdXONQtFYKJweYTuHolHeYGkAIIzfwonQvvxsnWNHEJWPahQwCpPNNpcRuyYhyqIUsbHXxGZGCFcsPmuGfgkXIIaOenQOXnRBgnISVXBPeVRjbDTvcfedlYqJeKoqAyCOzBubyRhIaPUNeWVLcSewGgsYRtMfsWCyzQbEkIoiVzYZIsOjtRYUPxaJJjhcaKMzIJftnVVUwnAPGjkloNqmhlQZKdWJDPJesQeqgmULFvwiQPpgsNemuFCvNQtSLjKKxZuBkaupYoTVPBrxiRUvEDCwXtFJglPMfriImqUOeUebGObLLzXLncJqIIEPXjxzoXLUsiDGGfzxGaQpZNRkWGiCklKKQjVUEwcoWFoeqxocQnHYxyEDccPugTHOrVqLIKlyPyxLPeHq", + "id": 1, + "name": "disaster-type-1", + "summary": "summary", "translation_module_original_language": "en", }, "end_date": "2008-01-01", @@ -130,9 +130,9 @@ "dtype": 1, "emergency_response_contact_email": None, "id": 2, - "name": "xNooiEjDVMxASJEWIZQnWpRWMYfHCHTxeKhdJGmKIjkuHChRnT", + "name": "event-1", "parent_event": 1, - "slug": "lffgczddigadkdjdrztubzqavnlecbwseideecsalxixpupaxy", + "slug": "event-slug", "start_date": None, "translation_module_original_language": "en", }, @@ -140,25 +140,25 @@ "modified_at": "2008-01-01T00:00:00.123456Z", "modified_by": None, "modified_by_detail": None, - "name": "project-yoHzwwFYEMaGiCkoeGPrnjlkxMThQoAZvUhEREEnLkPAbpciKL", - "operation_type": 0, - "operation_type_display": "Programme", + "name": "project-1", + "operation_type": 1, + "operation_type_display": "Emergency Operation", "primary_sector": 1, - "primary_sector_display": "sect-OhbVrpoiVgRVIfLBcbfnoGMbJmTPSIAoCLrZaWZkSBvrjnWvgf", + "primary_sector_display": "sect-1", "programme_type": 0, "programme_type_display": "Bilateral", "project_admin2": [], "project_admin2_detail": [], - "project_country": 2, + "project_country": 1, "project_country_detail": { - "id": 2, - "iso": "Cp", - "iso3": "xgR", - "name": "country-oEbNJuNoPeODStPAhicctFhgpIiyDxQVSIALVUjAPgFNArcSxn", - "society_name": "society-name-xIPwdzrmhDfQnPOMbdYvpiYKneWJnLnovXjYMarjiIqZlhQbia", + "id": 1, + "iso": "bV", + "iso3": "rpo", + "name": "country-1", + "society_name": "society-name-1", }, - "project_districts": [], - "project_districts_detail": [], + "project_districts": [1, 2], + "project_districts_detail": [{"id": 1, "name": "district-1"}, {"id": 2, "name": "district-2"}], "reached_female": 0, "reached_male": 0, "reached_other": 0, @@ -168,7 +168,7 @@ "created_at": "2008-01-01T00:00:00.123456Z", "id": 1, "modified_at": "2008-01-01T00:00:00.123456Z", - "name": "regional-project-fnCMEEkoAMjYLXlNQGqkURvDMLeoyyigbmHGRAjMglENMcYIGW", + "name": "regional-project-1", "translation_module_original_language": "en", "translation_module_skip_auto_translation": False, }, @@ -176,15 +176,9 @@ "reporting_ns_contact_email": None, "reporting_ns_contact_name": None, "reporting_ns_contact_role": None, - "reporting_ns_detail": { - "id": 1, - "iso": "yr", - "iso3": "OSJ", - "name": "country-wMqZcUDIhyfJsONxKmTecQoXsfogyrDOxkxwnQrSRPeMOkIUpk", - "society_name": "society-name-oRuXXdocZuzrenKTunPFzPDjqipVJIqVLBLzxoiGFfWdhjOkYR", - }, - "secondary_sectors": [], - "secondary_sectors_display": [], + "reporting_ns_detail": {"id": 1, "iso": "bV", "iso3": "rpo", "name": "country-1", "society_name": "society-name-1"}, + "secondary_sectors": [1, 2], + "secondary_sectors_display": ["sec-tag-1", "sec-tag-2"], "start_date": "2008-01-01", "status": 1, "status_display": "Ongoing", @@ -209,14 +203,14 @@ { "actual_expenditure": 0, "annual_splits": [], - "budget_amount": 6440000, + "budget_amount": 100000, "description": "", "document": None, - "dtype": 3, + "dtype": 1, "dtype_detail": { - "id": 3, - "name": "disaster-type-MSVGtSJuTVJOnmnNTsRwRiTPlGISOuThWwJELKQTARVIsBZaHg", - "summary": "byjdQdmrWYksRqjdSYsnWIcwCgNRVJoVPJypGYYZSsSQdyyAYRuJdaVqmNXCoOTTPxWLIVMmXUmsClRellVGhycBrJqikLqavDTjcjuMdXONQtFYKJweYTuHolHeYGkAIIzfwonQvvxsnWNHEJWPahQwCpPNNpcRuyYhyqIUsbHXxGZGCFcsPmuGfgkXIIaOenQOXnRBgnISVXBPeVRjbDTvcfedlYqJeKoqAyCOzBubyRhIaPUNeWVLcSewGgsYRtMfsWCyzQbEkIoiVzYZIsOjtRYUPxaJJjhcaKMzIJftnVVUwnAPGjkloNqmhlQZKdWJDPJesQeqgmULFvwiQPpgsNemuFCvNQtSLjKKxZuBkaupYoTVPBrxiRUvEDCwXtFJglPMfriImqUOeUebGObLLzXLncJqIIEPXjxzoXLUsiDGGfzxGaQpZNRkWGiCklKKQjVUEwcoWFoeqxocQnHYxyEDccPugTHOrVqLIKlyPyxLPeHq", + "id": 1, + "name": "disaster-type-1", + "summary": "summary", "translation_module_original_language": "en", }, "end_date": "2008-01-01", @@ -226,9 +220,9 @@ "dtype": 1, "emergency_response_contact_email": None, "id": 2, - "name": "xNooiEjDVMxASJEWIZQnWpRWMYfHCHTxeKhdJGmKIjkuHChRnT", + "name": "event-1", "parent_event": 1, - "slug": "lffgczddigadkdjdrztubzqavnlecbwseideecsalxixpupaxy", + "slug": "event-slug", "start_date": None, "translation_module_original_language": "en", }, @@ -236,25 +230,25 @@ "modified_at": "2008-01-01T00:00:00.123456Z", "modified_by": None, "modified_by_detail": None, - "name": "project-yoHzwwFYEMaGiCkoeGPrnjlkxMThQoAZvUhEREEnLkPAbpciKL", - "operation_type": 0, - "operation_type_display": "Programme", + "name": "project-1", + "operation_type": 1, + "operation_type_display": "Emergency Operation", "primary_sector": 1, - "primary_sector_display": "sect-OhbVrpoiVgRVIfLBcbfnoGMbJmTPSIAoCLrZaWZkSBvrjnWvgf", + "primary_sector_display": "sect-1", "programme_type": 0, "programme_type_display": "Bilateral", "project_admin2": [], "project_admin2_detail": [], - "project_country": 2, + "project_country": 1, "project_country_detail": { - "id": 2, - "iso": "Cp", - "iso3": "xgR", - "name": "country-oEbNJuNoPeODStPAhicctFhgpIiyDxQVSIALVUjAPgFNArcSxn", - "society_name": "society-name-xIPwdzrmhDfQnPOMbdYvpiYKneWJnLnovXjYMarjiIqZlhQbia", + "id": 1, + "iso": "bV", + "iso3": "rpo", + "name": "country-1", + "society_name": "society-name-1", }, - "project_districts": [], - "project_districts_detail": [], + "project_districts": [1, 2], + "project_districts_detail": [{"id": 1, "name": "district-1"}, {"id": 2, "name": "district-2"}], "reached_female": 0, "reached_male": 0, "reached_other": 0, @@ -264,7 +258,7 @@ "created_at": "2008-01-01T00:00:00.123456Z", "id": 1, "modified_at": "2008-01-01T00:00:00.123456Z", - "name": "regional-project-fnCMEEkoAMjYLXlNQGqkURvDMLeoyyigbmHGRAjMglENMcYIGW", + "name": "regional-project-1", "translation_module_original_language": "en", "translation_module_skip_auto_translation": False, }, @@ -272,15 +266,9 @@ "reporting_ns_contact_email": None, "reporting_ns_contact_name": None, "reporting_ns_contact_role": None, - "reporting_ns_detail": { - "id": 1, - "iso": "yr", - "iso3": "OSJ", - "name": "country-wMqZcUDIhyfJsONxKmTecQoXsfogyrDOxkxwnQrSRPeMOkIUpk", - "society_name": "society-name-oRuXXdocZuzrenKTunPFzPDjqipVJIqVLBLzxoiGFfWdhjOkYR", - }, - "secondary_sectors": [], - "secondary_sectors_display": [], + "reporting_ns_detail": {"id": 1, "iso": "bV", "iso3": "rpo", "name": "country-1", "society_name": "society-name-1"}, + "secondary_sectors": [1, 2], + "secondary_sectors_display": ["sec-tag-1", "sec-tag-2"], "start_date": "2008-01-01", "status": 1, "status_display": "Ongoing", @@ -297,26 +285,26 @@ { "actual_expenditure": 0, "annual_splits": [], - "budget_amount": 6090000, + "budget_amount": 100000, "description": "", "document": None, - "dtype": 6, + "dtype": 1, "dtype_detail": { - "id": 6, - "name": "disaster-type-blCoqPewfsGGIPfYroghexcImvmRvqtVXRrmTMiWTVIqaXtswY", - "summary": "zzLWPaEPGWjzooUVnEoHLYJWDUDvYfumBXSAnCCJbxiKitVaFZQwvoABRWzWXSItuLbKYcijvKOZMMKzynzeIymEgvKCOtfkgRJlcSMFblmeysnosQHeDdxHakuAzkhiIAEVeynintBTQEkMKtLmGTRDrmajCezMZpHvKFDDKcVfsPDwSTYtzNZlAplNUBDyQlSKgzScpkrOIsQeSUUnFAWJhxeWgGXXuACkqnGcDbeOSRVDyvVzmzcaqhTiuQVDFDefJQpTCiErkkbMglshIVzkeQWaRrjCwlnTcRInCSdOZHPQTQgyStCdMadXyXmpxpmfbAbavmRQeogZQkUkcAGguuJOmNnIzBhongwulazPuaynDoeQrPNxcenAtXMFgTIYKkqgMuOSyRXSivlOWSuQEevbMLCyGOVoGLTaobNWhtpVBWpNfdixFsmjynPcpUMCVviruPYWcHYAPsWboUvvpnIdQpZRSUoMyHulCOaeFemdOjni", + "id": 1, + "name": "disaster-type-1", + "summary": "summary", "translation_module_original_language": "en", }, "end_date": "2008-01-01", - "event": 4, + "event": 2, "event_detail": { "countries_for_preview": [], - "dtype": 4, + "dtype": 1, "emergency_response_contact_email": None, - "id": 4, - "name": "ZoHPvALvPPYuFLQSHJCDtKiYtkYqoExsXdjwsDkNkTIsllTSQY", - "parent_event": 3, - "slug": "jkphcukicqxlnjtcquwjxcikithbzfxjdujavigvptseswkqjz", + "id": 2, + "name": "event-1", + "parent_event": 1, + "slug": "event-slug", "start_date": None, "translation_module_original_language": "en", }, @@ -324,51 +312,45 @@ "modified_at": "2008-01-01T00:00:00.123456Z", "modified_by": None, "modified_by_detail": None, - "name": "project-flLJYnpGfBUDtkUmpBlMptsKCOmrYEfxzykECBGNVBWjYEbWyB", + "name": "project-1", "operation_type": 1, "operation_type_display": "Emergency Operation", "primary_sector": 1, - "primary_sector_display": "sect-OhbVrpoiVgRVIfLBcbfnoGMbJmTPSIAoCLrZaWZkSBvrjnWvgf", + "primary_sector_display": "sect-1", "programme_type": 0, "programme_type_display": "Bilateral", "project_admin2": [], "project_admin2_detail": [], - "project_country": 4, + "project_country": 1, "project_country_detail": { - "id": 4, - "iso": "rN", - "iso3": "OJn", - "name": "country-XkvKQjkjlXTdAttUXCsOlhimaNWqaDFFIZaMFpnLQEDACfMMap", - "society_name": "society-name-dljdPwcjcQKMtvfdgAlkRsNQSSMKYJlDVLxcfXtuxyeWBJesEi", + "id": 1, + "iso": "bV", + "iso3": "rpo", + "name": "country-1", + "society_name": "society-name-1", }, - "project_districts": [], - "project_districts_detail": [], + "project_districts": [1, 2], + "project_districts_detail": [{"id": 1, "name": "district-1"}, {"id": 2, "name": "district-2"}], "reached_female": 0, "reached_male": 0, "reached_other": 0, "reached_total": 0, - "regional_project": 2, + "regional_project": 1, "regional_project_detail": { "created_at": "2008-01-01T00:00:00.123456Z", - "id": 2, + "id": 1, "modified_at": "2008-01-01T00:00:00.123456Z", - "name": "regional-project-JMEeviTEmjmaaGUUxFzAzVxyFtPLeAchyKkmWBqXWUwGTFOSxS", + "name": "regional-project-1", "translation_module_original_language": "en", "translation_module_skip_auto_translation": False, }, - "reporting_ns": 3, + "reporting_ns": 1, "reporting_ns_contact_email": None, "reporting_ns_contact_name": None, "reporting_ns_contact_role": None, - "reporting_ns_detail": { - "id": 3, - "iso": "yP", - "iso3": "nSZ", - "name": "country-MIaXRPBHAxcSHBoZEYXywLZVWSKgBiqEXofsMIAqmaTVYaKHhH", - "society_name": "society-name-uAxgjBPLqqIBKxNrRzWnAJYJElxJJEqtKwXTzViQhVoCYSkgnG", - }, - "secondary_sectors": [], - "secondary_sectors_display": [], + "reporting_ns_detail": {"id": 1, "iso": "bV", "iso3": "rpo", "name": "country-1", "society_name": "society-name-1"}, + "secondary_sectors": [1, 2], + "secondary_sectors_display": ["sec-tag-1", "sec-tag-2"], "start_date": "2008-01-01", "status": 1, "status_display": "Ongoing", @@ -390,16 +372,11 @@ snapshots["TestProjectAPI::test_project_read 1"] = { "actual_expenditure": 0, "annual_splits": [], - "budget_amount": 6440000, + "budget_amount": 100000, "description": "", "document": None, - "dtype": 3, - "dtype_detail": { - "id": 3, - "name": "disaster-type-MSVGtSJuTVJOnmnNTsRwRiTPlGISOuThWwJELKQTARVIsBZaHg", - "summary": "byjdQdmrWYksRqjdSYsnWIcwCgNRVJoVPJypGYYZSsSQdyyAYRuJdaVqmNXCoOTTPxWLIVMmXUmsClRellVGhycBrJqikLqavDTjcjuMdXONQtFYKJweYTuHolHeYGkAIIzfwonQvvxsnWNHEJWPahQwCpPNNpcRuyYhyqIUsbHXxGZGCFcsPmuGfgkXIIaOenQOXnRBgnISVXBPeVRjbDTvcfedlYqJeKoqAyCOzBubyRhIaPUNeWVLcSewGgsYRtMfsWCyzQbEkIoiVzYZIsOjtRYUPxaJJjhcaKMzIJftnVVUwnAPGjkloNqmhlQZKdWJDPJesQeqgmULFvwiQPpgsNemuFCvNQtSLjKKxZuBkaupYoTVPBrxiRUvEDCwXtFJglPMfriImqUOeUebGObLLzXLncJqIIEPXjxzoXLUsiDGGfzxGaQpZNRkWGiCklKKQjVUEwcoWFoeqxocQnHYxyEDccPugTHOrVqLIKlyPyxLPeHq", - "translation_module_original_language": "en", - }, + "dtype": 1, + "dtype_detail": {"id": 1, "name": "disaster-type-1", "summary": "summary", "translation_module_original_language": "en"}, "end_date": "2008-01-01", "event": 2, "event_detail": { @@ -407,9 +384,9 @@ "dtype": 1, "emergency_response_contact_email": None, "id": 2, - "name": "xNooiEjDVMxASJEWIZQnWpRWMYfHCHTxeKhdJGmKIjkuHChRnT", + "name": "event-1", "parent_event": 1, - "slug": "lffgczddigadkdjdrztubzqavnlecbwseideecsalxixpupaxy", + "slug": "event-slug", "start_date": None, "translation_module_original_language": "en", }, @@ -417,25 +394,19 @@ "modified_at": "2008-01-01T00:00:00.123456Z", "modified_by": None, "modified_by_detail": None, - "name": "project-yoHzwwFYEMaGiCkoeGPrnjlkxMThQoAZvUhEREEnLkPAbpciKL", - "operation_type": 0, - "operation_type_display": "Programme", + "name": "project-1", + "operation_type": 1, + "operation_type_display": "Emergency Operation", "primary_sector": 1, - "primary_sector_display": "sect-OhbVrpoiVgRVIfLBcbfnoGMbJmTPSIAoCLrZaWZkSBvrjnWvgf", + "primary_sector_display": "sect-1", "programme_type": 0, "programme_type_display": "Bilateral", "project_admin2": [], "project_admin2_detail": [], - "project_country": 2, - "project_country_detail": { - "id": 2, - "iso": "Cp", - "iso3": "xgR", - "name": "country-oEbNJuNoPeODStPAhicctFhgpIiyDxQVSIALVUjAPgFNArcSxn", - "society_name": "society-name-xIPwdzrmhDfQnPOMbdYvpiYKneWJnLnovXjYMarjiIqZlhQbia", - }, - "project_districts": [], - "project_districts_detail": [], + "project_country": 1, + "project_country_detail": {"id": 1, "iso": "bV", "iso3": "rpo", "name": "country-1", "society_name": "society-name-1"}, + "project_districts": [1, 2], + "project_districts_detail": [{"id": 1, "name": "district-1"}, {"id": 2, "name": "district-2"}], "reached_female": 0, "reached_male": 0, "reached_other": 0, @@ -445,7 +416,7 @@ "created_at": "2008-01-01T00:00:00.123456Z", "id": 1, "modified_at": "2008-01-01T00:00:00.123456Z", - "name": "regional-project-fnCMEEkoAMjYLXlNQGqkURvDMLeoyyigbmHGRAjMglENMcYIGW", + "name": "regional-project-1", "translation_module_original_language": "en", "translation_module_skip_auto_translation": False, }, @@ -453,15 +424,9 @@ "reporting_ns_contact_email": None, "reporting_ns_contact_name": None, "reporting_ns_contact_role": None, - "reporting_ns_detail": { - "id": 1, - "iso": "yr", - "iso3": "OSJ", - "name": "country-wMqZcUDIhyfJsONxKmTecQoXsfogyrDOxkxwnQrSRPeMOkIUpk", - "society_name": "society-name-oRuXXdocZuzrenKTunPFzPDjqipVJIqVLBLzxoiGFfWdhjOkYR", - }, - "secondary_sectors": [], - "secondary_sectors_display": [], + "reporting_ns_detail": {"id": 1, "iso": "bV", "iso3": "rpo", "name": "country-1", "society_name": "society-name-1"}, + "secondary_sectors": [1, 2], + "secondary_sectors_display": ["sec-tag-1", "sec-tag-2"], "start_date": "2008-01-01", "status": 1, "status_display": "Ongoing", @@ -479,16 +444,11 @@ snapshots["TestProjectAPI::test_project_update 1"] = { "actual_expenditure": 0, "annual_splits": [], - "budget_amount": 6440000, + "budget_amount": 100000, "description": "", "document": None, - "dtype": 3, - "dtype_detail": { - "id": 3, - "name": "disaster-type-MSVGtSJuTVJOnmnNTsRwRiTPlGISOuThWwJELKQTARVIsBZaHg", - "summary": "byjdQdmrWYksRqjdSYsnWIcwCgNRVJoVPJypGYYZSsSQdyyAYRuJdaVqmNXCoOTTPxWLIVMmXUmsClRellVGhycBrJqikLqavDTjcjuMdXONQtFYKJweYTuHolHeYGkAIIzfwonQvvxsnWNHEJWPahQwCpPNNpcRuyYhyqIUsbHXxGZGCFcsPmuGfgkXIIaOenQOXnRBgnISVXBPeVRjbDTvcfedlYqJeKoqAyCOzBubyRhIaPUNeWVLcSewGgsYRtMfsWCyzQbEkIoiVzYZIsOjtRYUPxaJJjhcaKMzIJftnVVUwnAPGjkloNqmhlQZKdWJDPJesQeqgmULFvwiQPpgsNemuFCvNQtSLjKKxZuBkaupYoTVPBrxiRUvEDCwXtFJglPMfriImqUOeUebGObLLzXLncJqIIEPXjxzoXLUsiDGGfzxGaQpZNRkWGiCklKKQjVUEwcoWFoeqxocQnHYxyEDccPugTHOrVqLIKlyPyxLPeHq", - "translation_module_original_language": "en", - }, + "dtype": 1, + "dtype_detail": {"id": 1, "name": "disaster-type-1", "summary": "summary", "translation_module_original_language": "en"}, "end_date": "2008-01-01", "event": 2, "event_detail": { @@ -496,9 +456,9 @@ "dtype": 1, "emergency_response_contact_email": None, "id": 2, - "name": "xNooiEjDVMxASJEWIZQnWpRWMYfHCHTxeKhdJGmKIjkuHChRnT", + "name": "event-1", "parent_event": 1, - "slug": "lffgczddigadkdjdrztubzqavnlecbwseideecsalxixpupaxy", + "slug": "event-slug", "start_date": None, "translation_module_original_language": "en", }, @@ -507,24 +467,18 @@ "modified_by": 3, "modified_by_detail": {"email": "jon@dave.com", "first_name": "Jon", "id": 3, "last_name": "Mon", "username": "jon@dave.com"}, "name": "Mock Project for Update API Test", - "operation_type": 0, - "operation_type_display": "Programme", + "operation_type": 1, + "operation_type_display": "Emergency Operation", "primary_sector": 1, - "primary_sector_display": "sect-OhbVrpoiVgRVIfLBcbfnoGMbJmTPSIAoCLrZaWZkSBvrjnWvgf", + "primary_sector_display": "sect-1", "programme_type": 0, "programme_type_display": "Bilateral", "project_admin2": [], "project_admin2_detail": [], - "project_country": 3, - "project_country_detail": { - "id": 3, - "iso": "ay", - "iso3": "PnS", - "name": "country-iMIaXRPBHAxcSHBoZEYXywLZVWSKgBiqEXofsMIAqmaTVYaKHh", - "society_name": "society-name-ZuAxgjBPLqqIBKxNrRzWnAJYJElxJJEqtKwXTzViQhVoCYSkgn", - }, - "project_districts": [1], - "project_districts_detail": [{"id": 1, "name": "district-kyJycXkvKQjkjlXTdAttUXCsOlhimaNWqaDFFIZaMFpnLQEDAC"}], + "project_country": 2, + "project_country_detail": {"id": 2, "iso": "Te", "iso3": "frj", "name": "country-2", "society_name": "society-name-2"}, + "project_districts": [3], + "project_districts_detail": [{"id": 3, "name": "district-3"}], "reached_female": 0, "reached_male": 0, "reached_other": 0, @@ -534,23 +488,17 @@ "created_at": "2008-01-01T00:00:00.123456Z", "id": 1, "modified_at": "2008-01-01T00:00:00.123456Z", - "name": "regional-project-fnCMEEkoAMjYLXlNQGqkURvDMLeoyyigbmHGRAjMglENMcYIGW", + "name": "regional-project-1", "translation_module_original_language": "en", "translation_module_skip_auto_translation": False, }, - "reporting_ns": 3, + "reporting_ns": 2, "reporting_ns_contact_email": None, "reporting_ns_contact_name": None, "reporting_ns_contact_role": None, - "reporting_ns_detail": { - "id": 3, - "iso": "ay", - "iso3": "PnS", - "name": "country-iMIaXRPBHAxcSHBoZEYXywLZVWSKgBiqEXofsMIAqmaTVYaKHh", - "society_name": "society-name-ZuAxgjBPLqqIBKxNrRzWnAJYJElxJJEqtKwXTzViQhVoCYSkgn", - }, - "secondary_sectors": [], - "secondary_sectors_display": [], + "reporting_ns_detail": {"id": 2, "iso": "Te", "iso3": "frj", "name": "country-2", "society_name": "society-name-2"}, + "secondary_sectors": [1, 2], + "secondary_sectors_display": ["sec-tag-1", "sec-tag-2"], "start_date": "2008-01-01", "status": 1, "status_display": "Ongoing", diff --git a/deployments/tests.py b/deployments/tests.py index adaed03c1..e980ee967 100644 --- a/deployments/tests.py +++ b/deployments/tests.py @@ -56,8 +56,37 @@ def test_project_list_zero(self): def test_project_list_one(self): # create instance - sct = SectorFactory() - ProjectFactory.create(visibility=VisibilityCharChoices.PUBLIC, primary_sector=sct) + _country = country.CountryFactory(name="country-1", society_name="society-name-1") + sct = SectorFactory(title="sect-1", order=1) + sct_1 = SectorTagFactory(title="sec-tag-1", order=2) + sct_2 = SectorTagFactory(title="sec-tag-2", order=3) + district1 = district.DistrictFactory(country=_country, name="district-1", code="dct1") + district2 = district.DistrictFactory(country=_country, name="district-2", code="dct2") + dtype = DisasterTypeFactory(name="disaster-type-1", summary="summary") + regional_project = RegionalProjectFactory(name="regional-project-1") + event = EventFactory( + countries=[_country.id], + slug="event-slug", + districts=[district1.id, district2.id], + dtype=dtype, + name="event-1", + ) + ProjectFactory.create( + name="project-1", + project_districts=[district1, district2], + budget_amount=100000, + primary_sector=sct, + event=event, + regional_project=regional_project, + secondary_sectors=[sct_1, sct_2], + dtype=dtype, + visibility=VisibilityCharChoices.PUBLIC, + project_country=_country, + reporting_ns=_country, + status=Statuses.COMPLETED, + programme_type=ProgrammeTypes.BILATERAL, + operation_type=OperationTypes.EMERGENCY_OPERATION, + ) # submit list request response = self.client.get("/api/v2/project/") @@ -68,8 +97,38 @@ def test_project_list_one(self): def test_project_list_two(self): # create instances - sct = SectorFactory() - ProjectFactory.create_batch(2, visibility=VisibilityCharChoices.PUBLIC, primary_sector=sct) + _country = country.CountryFactory(name="country-1", society_name="society-name-1") + sct = SectorFactory(title="sect-1", order=1) + sct_1 = SectorTagFactory(title="sec-tag-1", order=2) + sct_2 = SectorTagFactory(title="sec-tag-2", order=3) + district1 = district.DistrictFactory(country=_country, name="district-1", code="dct1") + district2 = district.DistrictFactory(country=_country, name="district-2", code="dct2") + dtype = DisasterTypeFactory(name="disaster-type-1", summary="summary") + regional_project = RegionalProjectFactory(name="regional-project-1") + event = EventFactory( + countries=[_country.id], + slug="event-slug", + districts=[district1.id, district2.id], + dtype=dtype, + name="event-1", + ) + ProjectFactory.create_batch( + 2, + name="project-1", + project_districts=[district1, district2], + budget_amount=100000, + primary_sector=sct, + event=event, + regional_project=regional_project, + secondary_sectors=[sct_1, sct_2], + dtype=dtype, + visibility=VisibilityCharChoices.PUBLIC, + project_country=_country, + reporting_ns=_country, + status=Statuses.COMPLETED, + programme_type=ProgrammeTypes.BILATERAL, + operation_type=OperationTypes.EMERGENCY_OPERATION, + ) # submit list request response = self.client.get("/api/v2/project/") @@ -89,6 +148,7 @@ def test_project_create(self): name=new_project_name, visibility=VisibilityCharChoices.PUBLIC, user=new_user, + operation_type=OperationTypes.PROGRAMME, ) new_country = country.CountryFactory() new_district = district.DistrictFactory(country=new_country) @@ -121,8 +181,37 @@ def test_project_create(self): def test_project_read(self): # create instance - sct = SectorFactory() - new_project = ProjectFactory.create(visibility=VisibilityCharChoices.PUBLIC, primary_sector=sct) + _country = country.CountryFactory(name="country-1", society_name="society-name-1") + sct = SectorFactory(title="sect-1", order=1) + sct_1 = SectorTagFactory(title="sec-tag-1", order=2) + sct_2 = SectorTagFactory(title="sec-tag-2", order=3) + district1 = district.DistrictFactory(country=_country, name="district-1", code="dct1") + district2 = district.DistrictFactory(country=_country, name="district-2", code="dct2") + dtype = DisasterTypeFactory(name="disaster-type-1", summary="summary") + regional_project = RegionalProjectFactory(name="regional-project-1") + event = EventFactory( + countries=[_country.id], + slug="event-slug", + districts=[district1.id, district2.id], + dtype=dtype, + name="event-1", + ) + new_project = ProjectFactory.create( + name="project-1", + project_districts=[district1, district2], + budget_amount=100000, + primary_sector=sct, + event=event, + regional_project=regional_project, + secondary_sectors=[sct_1, sct_2], + dtype=dtype, + visibility=VisibilityCharChoices.PUBLIC, + project_country=_country, + reporting_ns=_country, + status=Statuses.COMPLETED, + programme_type=ProgrammeTypes.BILATERAL, + operation_type=OperationTypes.EMERGENCY_OPERATION, + ) # submit read request response = self.client.get(f"/api/v2/project/{new_project.pk}/") @@ -133,8 +222,37 @@ def test_project_read(self): def test_project_update(self): # create instance - sct = SectorFactory() - new_project = ProjectFactory.create(visibility=VisibilityCharChoices.PUBLIC, primary_sector=sct) + _country = country.CountryFactory(name="country-1", society_name="society-name-1") + sct = SectorFactory(title="sect-1", order=1) + sct_1 = SectorTagFactory(title="sec-tag-1", order=2) + sct_2 = SectorTagFactory(title="sec-tag-2", order=3) + district1 = district.DistrictFactory(country=_country, name="district-1", code="dct1") + district2 = district.DistrictFactory(country=_country, name="district-2", code="dct2") + dtype = DisasterTypeFactory(name="disaster-type-1", summary="summary") + regional_project = RegionalProjectFactory(name="regional-project-1") + event = EventFactory( + countries=[_country.id], + slug="event-slug", + districts=[district1.id, district2.id], + dtype=dtype, + name="event-1", + ) + new_project = ProjectFactory.create( + name="project-1", + project_districts=[district1, district2], + budget_amount=100000, + primary_sector=sct, + event=event, + regional_project=regional_project, + secondary_sectors=[sct_1, sct_2], + dtype=dtype, + visibility=VisibilityCharChoices.PUBLIC, + project_country=_country, + reporting_ns=_country, + status=Statuses.COMPLETED, + programme_type=ProgrammeTypes.BILATERAL, + operation_type=OperationTypes.EMERGENCY_OPERATION, + ) # authenticate self.authenticate() @@ -145,8 +263,15 @@ def test_project_update(self): ) # update project name new_project_name = "Mock Project for Update API Test" - new_country = country.CountryFactory() - new_district = district.DistrictFactory(country=new_country) + new_country = country.CountryFactory( + name="country-2", + society_name="society-name-2", + ) + new_district = district.DistrictFactory( + country=new_country, + name="district-3", + code="dct3", + ) new_project["name"] = new_project_name new_project["reporting_ns"] = new_country.id new_project["project_country"] = new_country.id diff --git a/dref/serializers.py b/dref/serializers.py index 27d0b4ce0..6cbc747c9 100644 --- a/dref/serializers.py +++ b/dref/serializers.py @@ -42,18 +42,24 @@ class RiskSecuritySerializer(ModelSerializer): + id = serializers.IntegerField(required=False) + class Meta: model = RiskSecurity fields = "__all__" class SourceInformationSerializer(ModelSerializer): + id = serializers.IntegerField(required=False) + class Meta: model = SourceInformation fields = "__all__" class PlannedInterventionIndicatorsSerializer(ModelSerializer): + id = serializers.IntegerField(required=False) + class Meta: model = PlannedInterventionIndicators fields = "__all__" @@ -274,8 +280,13 @@ def get_unpublished_final_report_count(self, obj) -> int: return DrefFinalReport.objects.filter(dref_id=obj.id, is_published=False).count() -class PlannedInterventionSerializer(ModelSerializer): +class PlannedInterventionSerializer( + NestedCreateMixin, + NestedUpdateMixin, + ModelSerializer, +): # budget_file_details = DrefFileSerializer(source="budget_file", read_only=True) + id = serializers.IntegerField(required=False) image_url = serializers.SerializerMethodField() indicators = PlannedInterventionIndicatorsSerializer(many=True, required=False) title_display = serializers.CharField(source="get_title_display", read_only=True) @@ -284,20 +295,6 @@ class Meta: model = PlannedIntervention fields = "__all__" - def create(self, validated_data): - indicators = validated_data.pop("indicators", []) - intervention = super().create(validated_data) - for indicator in indicators: - ind_object = PlannedInterventionIndicators.objects.create(**indicator) - intervention.indicators.add(ind_object) - return intervention - - def update(self, instance, validated_data): - # TODO: implement this - # indicators = validated_data.pop("indicators", []) - intervention = super().update(instance, validated_data) - return intervention - def get_image_url(self, plannedintervention) -> str: title = plannedintervention.title if title and self.context and "request" in self.context: @@ -307,6 +304,7 @@ def get_image_url(self, plannedintervention) -> str: class NationalSocietyActionSerializer(ModelSerializer): + id = serializers.IntegerField(required=False) image_url = serializers.SerializerMethodField() title_display = serializers.CharField(source="get_title_display", read_only=True) @@ -329,6 +327,7 @@ def get_image_url(self, nationalsocietyactions) -> str: class IdentifiedNeedSerializer(ModelSerializer): + id = serializers.IntegerField(required=False) image_url = serializers.SerializerMethodField() title_display = serializers.CharField(source="get_title_display", read_only=True) diff --git a/dref/test_views.py b/dref/test_views.py index dfa4353fc..372577a3e 100644 --- a/dref/test_views.py +++ b/dref/test_views.py @@ -180,7 +180,23 @@ def test_post_dref_creation(self, send_notification): "originator_email": "test@gmail.com", "national_society": national_society.id, "disaster_type": disaster_type.id, - "needs_identified": [{"title": "shelter_housing_and_settlements", "description": "hey"}], + # NOTE: Test Many to Many fields + "risk_security": [ + {"risk": "Test Risk 1", "mitigation_measure": "Test Mitigation Measure"}, + {"risk": "Test Risk 2", "mitigation_measure": "Test Mitigation Measure 1"}, + ], + "source_information": [ + {"source_name": "Test Source 1", "link": "http://test.com"}, + {"source_name": "Test Source 2", "link": "http://test.com"}, + ], + "needs_identified": [ + {"title": "shelter_housing_and_settlements", "description": "Shelter"}, + {"title": "health", "description": "Health"}, + ], + "national_society_actions": [ + {"title": "coordination", "description": "Coordination"}, + {"title": "shelter_housing_and_settlements", "description": "Shelter"}, + ], "planned_interventions": [ { "title": "shelter_housing_and_settlements", @@ -190,14 +206,18 @@ def test_post_dref_creation(self, send_notification): "female": 2255, "indicators": [ { - "title": "test_title", + "title": "test_title_1", "actual": 21232, "target": 44444, - } + }, + { + "title": "test_title_2", + "actual": 21232, + "target": 44444, + }, ], }, { - "id": 2, "title": "health", "description": "matrix reloaded", "budget": 451111111, @@ -205,10 +225,15 @@ def test_post_dref_creation(self, send_notification): "female": 2255, "indicators": [ { - "title": "test_title", + "title": "test_title_2", "actual": 21232, "target": 44444, - } + }, + { + "title": "test_title_2", + "actual": 21232, + "target": 44444, + }, ], }, ], @@ -228,6 +253,231 @@ def test_post_dref_creation(self, send_notification): self.assertTrue(send_notification.assert_called) self.assertEqual(email_data["title"], instance.title) + # Testing Nested objects creation and update + # Update the created dref + data = { + "modified_at": datetime.now(), + **data, + "risk_security": [ + {"id": response.data["risk_security"][0]["id"], "risk": "Updated Test Risk 1", "mitigation_measure": "Test"}, + { + "id": response.data["risk_security"][1]["id"], + "risk": "Updated Test Risk 2", + "mitigation_measure": "Test Mitigation Measure 2", + }, + # New item to be added + {"risk": "New Test Risk", "mitigation_measure": "New Test Mitigation Measure"}, + ], + "source_information": [ + { + "id": response.data["source_information"][0]["id"], + "source_name": "Updated Test Source 1", + "link": "http://updated.com", + }, + { + "id": response.data["source_information"][1]["id"], + "source_name": "Updated Test Source 2", + "link": "http://updated.com", + }, + # New item to be added + {"source_name": "New Test Source", "link": "http://new.com"}, + ], + "needs_identified": [ + { + "id": response.data["needs_identified"][0]["id"], + "title": "shelter_housing_and_settlements", + "description": "Updated Shelter", + }, + {"id": response.data["needs_identified"][1]["id"], "title": "health", "description": "Updated Health"}, + # New item to be added + {"title": "water_sanitation_and_hygiene", "description": "WASH"}, + ], + "national_society_actions": [ + { + "id": response.data["national_society_actions"][0]["id"], + "title": "coordination", + "description": "Updated Coordination", + }, + { + "id": response.data["national_society_actions"][1]["id"], + "title": "shelter_housing_and_settlements", + "description": "Updated Shelter", + }, + # New item to be added + {"title": "health", "description": "Health"}, + ], + "planned_interventions": [ + { + "id": response.data["planned_interventions"][0]["id"], + "title": "shelter_housing_and_settlements", + "description": "Updated matrix", + "budget": 99999, + "male": 12222, + "female": 2255, + "indicators": [ + { + "id": response.data["planned_interventions"][0]["indicators"][0]["id"], + "title": "updated_test_title_1", + "actual": 11111, + "target": 22222, + }, + { + "id": response.data["planned_interventions"][0]["indicators"][1]["id"], + "title": "updated_test_title_2", + "actual": 33333, + "target": 44444, + }, + # New item to be added + { + "title": "new_test_title_3", + "actual": 55555, + "target": 66666, + }, + ], + }, + { + "id": response.data["planned_interventions"][1]["id"], + "title": "health", + "description": "Updated matrix reloaded", + "budget": 88888, + "male": 12222, + "female": 2255, + "indicators": [ + { + "id": response.data["planned_interventions"][1]["indicators"][0]["id"], + "title": "updated_test_title_1", + "actual": 11111, + "target": 22222, + }, + { + "id": response.data["planned_interventions"][1]["indicators"][1]["id"], + "title": "updated_test_title_2", + "actual": 33333, + "target": 44444, + }, + # New item to be added + { + "title": "new_test_title_3", + "actual": 55555, + "target": 66666, + }, + ], + }, + ], + } + + # Update the created dref + url = f"/api/v2/dref/{instance.id}/" + response = self.client.patch(url, data, format="json") + self.assert_200(response) + + # Risk Security should have 3 items now + self.assertEqual(len(response.data["risk_security"]), 3) + self.assertEqual( + { + response.data["risk_security"][0]["id"], + response.data["risk_security"][1]["id"], + response.data["risk_security"][2]["risk"], + }, + { + data["risk_security"][0].get("id"), + data["risk_security"][1].get("id"), + data["risk_security"][2].get("risk"), + }, + ) + + # Source of Information should have 3 items now + self.assertEqual(len(response.data["source_information"]), 3) + self.assertEqual( + { + response.data["source_information"][0]["id"], + response.data["source_information"][0]["source_name"], + response.data["source_information"][1]["id"], + response.data["source_information"][1]["source_name"], + response.data["source_information"][2]["source_name"], + }, + { + data["source_information"][0].get("id"), + data["source_information"][0].get("source_name"), + data["source_information"][1].get("id"), + data["source_information"][1].get("source_name"), + data["source_information"][2].get("source_name"), + }, + ) + + # Needs Identified should have 3 items mock_now + self.assertEqual(len(response.data["needs_identified"]), 3) + self.assertEqual( + { + response.data["needs_identified"][0]["id"], + response.data["needs_identified"][0]["title"], + response.data["needs_identified"][1]["id"], + response.data["needs_identified"][1]["title"], + response.data["needs_identified"][2]["title"], + }, + { + data["needs_identified"][0].get("id"), + data["needs_identified"][0].get("title"), + data["needs_identified"][1].get("id"), + data["needs_identified"][1].get("title"), + data["needs_identified"][2].get("title"), + }, + ) + + # National Society Actions should have 3 items mock_now + self.assertEqual(len(response.data["national_society_actions"]), 3) + self.assertEqual( + { + response.data["national_society_actions"][0]["id"], + response.data["national_society_actions"][0]["title"], + response.data["national_society_actions"][1]["id"], + response.data["national_society_actions"][1]["title"], + response.data["national_society_actions"][2]["title"], + }, + { + data["national_society_actions"][0].get("id"), + data["national_society_actions"][0].get("title"), + data["national_society_actions"][1].get("id"), + data["national_society_actions"][1].get("title"), + data["national_society_actions"][2].get("title"), + }, + ) + + # Planned Interventions should have 2 items + self.assertEqual(len(response.data["planned_interventions"]), 2) + self.assertEqual( + { + response.data["planned_interventions"][0]["id"], + response.data["planned_interventions"][0]["title"], + response.data["planned_interventions"][1]["id"], + response.data["planned_interventions"][1]["title"], + }, + { + data["planned_interventions"][0].get("id"), + data["planned_interventions"][0].get("title"), + data["planned_interventions"][1].get("id"), + data["planned_interventions"][1].get("title"), + }, + ) + + # Planned Intervention - Indicators should have 3 items now + self.assertEqual( + { + response.data["planned_interventions"][0]["indicators"][0]["id"], + response.data["planned_interventions"][0]["indicators"][0]["title"], + response.data["planned_interventions"][0]["indicators"][1]["id"], + response.data["planned_interventions"][0]["indicators"][1]["title"], + response.data["planned_interventions"][0]["indicators"][2]["title"], + }, + { + data["planned_interventions"][0]["indicators"][0].get("id"), + data["planned_interventions"][0]["indicators"][0].get("title"), + data["planned_interventions"][0]["indicators"][1].get("id"), + data["planned_interventions"][0]["indicators"][1].get("title"), + data["planned_interventions"][0]["indicators"][2].get("title"), + }, + ) + def test_event_date_in_dref(self): """ Test for the event date based on type_of_onset diff --git a/dref/translation.py b/dref/translation.py index 5db4d4132..435730faf 100644 --- a/dref/translation.py +++ b/dref/translation.py @@ -45,35 +45,6 @@ class DrefTO(TranslationOptions): "communication", "risk_security_concern", ) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ( - "ns_request_text", - "dref_recurrent_text", - "lessons_learned", - "child_safeguarding_risk_level", - "event_description", - "anticipatory_actions", - "event_scope", - "national_authorities", - "ifrc", - "icrc", - "partner_national_society", - "un_or_other_actor", - "major_coordination_mechanism", - "identified_gaps", - "people_assisted", - "selection_criteria", - "operation_objective", - "response_strategy", - "human_resource", - "is_volunteer_team_diverse", - "surge_personnel_deployed", - "logistic_capacity_of_ns", - "pmer", - "communication", - "risk_security_concern", - ) @register(DrefFile) @@ -106,26 +77,6 @@ class DrefFinalReportTO(TranslationOptions): "national_society_conducted_description", "financial_report_description", ) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ( - "event_description", - "anticipatory_actions", - "event_scope", - "ifrc", - "icrc", - "partner_national_society", - "national_authorities", - "un_or_other_actor", - "selection_criteria", - "operation_objective", - "response_strategy", - "major_coordination_mechanism", - "risk_security_concern", - "event_text", - "national_society_conducted_description", - "financial_report_description", - ) @register(DrefOperationalUpdate) @@ -155,29 +106,6 @@ class DrefOperationalUpdateTO(TranslationOptions): "pmer", "communication", ) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ( - "event_scope", - "ifrc", - "icrc", - "partner_national_society", - "national_authorities", - "un_or_other_actor", - "major_coordination_mechanism", - "people_assisted", - "selection_criteria", - "operation_objective", - "response_strategy", - "risk_security_concern", - "anticipatory_to_response", - "human_resource", - "is_volunteer_team_diverse", - "surge_personnel_deployed", - "logistic_capacity_of_ns", - "pmer", - "communication", - ) @register(IdentifiedNeed) @@ -186,12 +114,6 @@ class IdentifiedNeedTO(TranslationOptions): "title", "description", ) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ( - "title", - "description", - ) @register(NationalSocietyAction) @@ -212,24 +134,11 @@ class PlannedInterventionTO(TranslationOptions): "challenges", "lessons_learnt", ) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ( - "title", - "description", - "progress_towards_outcome", - "narrative_description_of_achievements", - "challenges", - "lessons_learnt", - ) @register(PlannedInterventionIndicators) class PlannedInterventionIndicatorsTO(TranslationOptions): fields = ("title",) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ("title",) @register(RiskSecurity) @@ -238,9 +147,3 @@ class RiskSecurityTO(TranslationOptions): "risk", "mitigation", ) - # NOTE: Adding skip_fields temporarily to avoid removing previously translated data - # TODO(sudip): Remove skip_fields after dref translation feature is implemented - skip_fields = ( - "risk", - "mitigation", - )