def setUp(self): super(TestInterventionResultModelExport, self).setUp() indicator = IndicatorFactory() self.link = InterventionResultLinkFactory( intervention=self.intervention, ) self.link.ram_indicators.add(indicator)
def test_process_indicators_add_result(self): """Check that result is added to indicator, if found""" result = ResultFactory( result_type=self.result_type_output, wbs="1234/56/78/90A/BCD" ) indicator = IndicatorFactory( code="WBS", name="NAME", baseline="BLINE", target="Target", ) response = self.adapter.process_indicators([self.data]) self.assertEqual(response, { "details": "Created Skipped 0\n" "Updated Skipped 0\n" "Created 0\n" "Indicators Updated to Active 0\n" "Indicators Updated to Inactive 0\n" "Updated 1", "total_records": 1, "processed": 1 }) indicator_updated = Indicator.objects.get(pk=indicator.pk) self.assertEqual(indicator_updated.result, result)
def test_process_indicators_wbs_not_found(self): """Check that NO update happens if result wbs differs and NOT found update is skipped """ result = ResultFactory( result_type=self.result_type_output, wbs="1234/56/78/90A/EFG" ) IndicatorFactory( code="WBS", name="NAME", baseline="BLINE", target="Target", result=result ) response = self.adapter.process_indicators([self.data]) self.assertEqual(response, { "details": "Created Skipped 0\n" "Updated Skipped 1\n" "Created 0\n" "Indicators Updated to Active 0\n" "Indicators Updated to Inactive 0\n" "Updated 0", "total_records": 1, "processed": 0 }) result_updated = Result.objects.get(pk=result.pk) self.assertEqual(result_updated.wbs, result.wbs)
def setUp(self): super(TestInterventionIndicatorModelExport, self).setUp() self.indicator = IndicatorFactory( name="Name", code="Code" ) self.link = InterventionResultLinkFactory( intervention=self.intervention, ) self.link.ram_indicators.add(self.indicator)
def test_process_indicators_result_not_found(self): """Check that NO update happens if no result and result wbs NOT found update is skipped """ indicator = IndicatorFactory( code="WBS", name="NAME", baseline="BLINE", target="Target", ) response = self.adapter.process_indicators([self.data]) self.assertEqual(response, { "details": "Created Skipped 0\n" "Updated Skipped 0\n" "Created 0\n" "Indicators Updated to Active 0\n" "Indicators Updated to Inactive 0\n" "Updated 0", "total_records": 1, "processed": 0 }) indicator_updated = Indicator.objects.get(pk=indicator.pk) self.assertIsNone(indicator_updated.result)
def setUpTestData(cls): cls.unicef_staff = UserFactory(is_staff=True) cls.result = ResultFactory() cls.indicator = IndicatorFactory(result=cls.result) cls.url = reverse("result-indicator-list", args=[cls.result.pk])