def test_micro_assessment(self): purchase_order = PurchaseOrderFactory.build(order_number='two') instance = MicroAssessmentFactory.build(agreement=purchase_order) self.assertIn(' two,', str(instance)) purchase_order = PurchaseOrderFactory.build(order_number='tv\xe5') instance = MicroAssessmentFactory.build(agreement=purchase_order) self.assertIn(' tv\xe5,', str(instance))
def test_micro_assessment(self): purchase_order = PurchaseOrderFactory.build(order_number='two') instance = MicroAssessmentFactory.build(agreement=purchase_order) self.assertIn(' two,', str(instance)) purchase_order = PurchaseOrderFactory.build(order_number='tv\xe5') instance = MicroAssessmentFactory.build(agreement=purchase_order) self.assertIn(' tv\xe5,', str(instance))
def test_detail_finding_info(self): purchase_order = PurchaseOrderFactory.build(order_number='two') micro = MicroAssessmentFactory.build(agreement=purchase_order) instance = DetailedFindingInfoFactory.build(micro_assesment=micro) self.assertIn(' two,', str(instance)) purchase_order = PurchaseOrderFactory.build(order_number='tv\xe5') micro = MicroAssessmentFactory.build(agreement=purchase_order) instance = DetailedFindingInfoFactory.build(micro_assesment=micro) self.assertIn(' tv\xe5,', str(instance))
def test_detail_finding_info(self): purchase_order = PurchaseOrderFactory.build(order_number='two') micro = MicroAssessmentFactory.build(agreement=purchase_order) instance = DetailedFindingInfoFactory.build(micro_assesment=micro) self.assertIn(' two,', str(instance)) purchase_order = PurchaseOrderFactory.build(order_number='tv\xe5') micro = MicroAssessmentFactory.build(agreement=purchase_order) instance = DetailedFindingInfoFactory.build(micro_assesment=micro) self.assertIn(' tv\xe5,', str(instance))
def test_create_linked(self): # no email should be send for now related_object = MicroAssessmentFactory() mail.outbox = [] ActionPointFactory(engagement=related_object) self.assertEqual(len(mail.outbox), 0)
def test_single_csv(self): action_point = ActionPointFactory(status='open', comments__count=1, engagement=MicroAssessmentFactory()) self._test_export(self.pme_user, 'action-points:action-points-export/csv', args=[action_point.id])
def test_list_csv(self): ActionPointFactory(status='open', comments__count=1) ActionPointFactory(status='open', comments__count=1, engagement=MicroAssessmentFactory()) ActionPointFactory(status='open', comments__count=1, tpm_activity=TPMVisitFactory( tpm_activities__count=1).tpm_activities.first()) self._test_export(self.pme_user, 'action-points:action-points-export/csv')
def test_get_assurance_activities(self): SpecialAuditFactory( status=Engagement.FINAL, date_of_draft_report_to_unicef=datetime(datetime.today().year, 2, 3)) SpecialAuditFactory( status=Engagement.FINAL, date_of_draft_report_to_unicef=datetime(datetime.today().year - 1, 2, 3)) MicroAssessmentFactory( status=Engagement.FINAL, date_of_draft_report_to_unicef=datetime(datetime.today().year, 8, 10)) assurance_activities = self.aggregate_hact.get_assurance_activities() self.assertEqual(len(list(assurance_activities.keys())), 6) self.assertEqual(assurance_activities['programmatic_visits']['completed'], 0) self.assertEqual(assurance_activities['programmatic_visits']['min_required'], 5) self.assertEqual(assurance_activities['spot_checks']['completed'], 0) self.assertEqual(assurance_activities['spot_checks']['min_required'], 1) self.assertEqual(assurance_activities['scheduled_audit'], 1) self.assertEqual(assurance_activities['special_audit'], 1) self.assertEqual(assurance_activities['micro_assessment'], 1)
def test_list_csv(self): ActionPointFactory(status='open', comments__count=1) ActionPointFactory(status='open', comments__count=1, engagement=MicroAssessmentFactory()) ActionPointFactory(status='open', comments__count=1, tpm_activity=TPMVisitFactory( tpm_activities__count=1).tpm_activities.first()) traveler = UserFactory() ActionPointFactory(status='open', travel_activity=TravelActivityFactory( primary_traveler=traveler, travels=[TravelFactory(traveler=traveler)])) self._test_export(self.pme_user, 'action-points:action-points-export/csv')
def test_update_related_category(self): action_point = ActionPointFactory(status='open', comments__count=0, engagement=MicroAssessmentFactory()) response = self.forced_auth_req( 'patch', reverse('action-points:action-points-detail', args=(action_point.id, )), user=action_point.author, data={ 'category': ActionPointCategoryFactory( module=Category.MODULE_CHOICES.audit).id }) self.assertEqual(response.status_code, status.HTTP_200_OK)
def setUp(self): super(TestRelatedOpenActionPointDetailViewMetadata, self).setUp() self.action_point.engagement = MicroAssessmentFactory() self.action_point.save()
def test_engagement_subclass(self): action_point = ActionPointFactory(engagement=MicroAssessmentFactory()) self.assertEqual( type(ActionPoint.objects.get(pk=action_point.pk).related_object), MicroAssessment)
def test_audit_related(self): action_point = ActionPointFactory(engagement=MicroAssessmentFactory()) self.assertEqual(action_point.related_module, ActionPoint.MODULE_CHOICES.audit)
def setUp(self): super().setUp() self.action_point.engagement = MicroAssessmentFactory() self.action_point.save()
def setUpTestData(cls): cls.user = UserFactory() cls.microassessment = MicroAssessmentFactory() cls.attachment = AttachmentFactory(content_object=cls.microassessment)
def test_audit_related_str(self): action_point = ActionPointFactory(engagement=MicroAssessmentFactory()) self.assertEqual( action_point.related_object_str, 'Micro Assessment {}'.format( action_point.engagement.reference_number))