コード例 #1
0
 def test_multiple_sectors(self):
     program = RFProgramFactory()
     sector = SectorFactory(program=program)
     sector2 = SectorFactory(program=program)
     RFIndicatorFactory(program=program, sector=sector)
     RFIndicatorFactory(program=program, sector=sector2)
     data = get_serialized_data(program.pk)
     self.assertEqual(len(data['sectors']), 2)
     self.assertEqual(set(sd['pk'] for sd in data['sectors']),
                      set([sector.pk, sector2.pk]))
コード例 #2
0
 def test_one_duplicated_sector(self):
     program = RFProgramFactory()
     sector = SectorFactory(program=program)
     RFIndicatorFactory(program=program, sector=sector)
     RFIndicatorFactory(program=program, sector=sector)
     data = get_serialized_data(program.pk)
     self.assertEqual(len(data['sectors']), 1)
コード例 #3
0
 def test_one_sector(self):
     program = RFProgramFactory()
     sector = SectorFactory(program=program)
     RFIndicatorFactory(program=program, sector=sector)
     data = get_serialized_data(program.pk)
     self.assertEqual(len(data['sectors']), 1)
     self.assertEqual(data['sectors'][0]['pk'], sector.pk)
     self.assertEqual(data['sectors'][0]['name'], sector.sector)
コード例 #4
0
 def setUp(self):
     super(CSVIndicatorTestBase, self).setUp()
     self.sectors = [SectorFactory(),]
     self.levels = [LevelFactory(),]
     self.disaggregations = [DisaggregationTypeFactory(),]
     self.indicatortypes = [IndicatorTypeFactory(),]
     self.indicators = []
     self.response = None
コード例 #5
0
 def test_two_indicators_different_relations(self):
     self.add_indicator()
     self.sectors.append(SectorFactory())
     self.add_indicator(sector=1)
     _, indicator_rows = self.get_rows()
     self.assertNotEqual(self.sectors[0].sector, self.sectors[1].sector,
                         "test invalid if sectors have same name")
     self.assertNotEqual(indicator_rows[0][6], indicator_rows[1][6],
                         self.assert_msg("sectors have different names, cells must be different also"))
     self.assertEqual(indicator_rows[0][6], self.sectors[0].sector,
                      self.assert_msg("different levels should show differently, got {0} instead of {1}".format(
                          indicator_rows[0][6], self.sectors[0].sector)))
     self.assertEqual(indicator_rows[1][6], self.sectors[1].sector,
                      self.assert_msg("different levels should show differently, got {0} instead of {1}".format(
                          indicator_rows[1][6], self.sectors[1].sector)))
コード例 #6
0
 def test_rf_program_two_indicators(self):
     p = RFProgramFactory(tiers=['Tier1', 'Tier2'],
                          levels=1,
                          reporting_period_start=datetime.date(2014, 5, 1))
     site = SiteProfileFactory()
     it = IndicatorTypeFactory()
     sector = SectorFactory()
     indicators = [
         RFIndicatorFactory(program=p,
                            level=level,
                            target_frequency=Indicator.LOP,
                            targets=500,
                            results=400) for level in p.levels.all()
     ]
     levels = sorted(p.levels.all(), key=lambda l: l.level_depth)
     level_pks = [{
         'pk': level.pk,
         'indicator_pks': [indicator.pk]
     } for level, indicator in zip(levels, indicators)]
     indicators[0].indicator_type.add(it)
     indicators[1].sector = sector
     indicators[1].save()
     indicators[0].result_set.first().site.add(site)
     indicators[1].result_set.first().site.add(site)
     with self.assertNumQueries(IPTT_QUERY_COUNT):
         data = get_serialized_data(p.pk)
     self.assertEqual(data['pk'], p.pk)
     self.assertEqual(data['name'], p.name)
     self.assertTrue(data['results_framework'])
     self.assertEqual(data['by_result_chain'], 'by Tier2 chain')
     self.assertEqual(data['reporting_period_start_iso'], '2014-05-01')
     self.assertEqual(data['frequencies'], [Indicator.LOP])
     self.assertEqual(data['sites'], [{'pk': site.pk, 'name': site.name}])
     self.assertEqual(data['sectors'], [{
         'pk': sector.pk,
         'name': sector.sector
     }])
     self.assertEqual(data['indicator_types'], [{
         'pk': it.pk,
         'name': it.indicator_type
     }])
     self.assertEqual(data['unassigned_indicator_pks'], [])
     self.assertEqual(data['level_pks_level_order'], [l.pk for l in levels])
     self.assertEqual(data['level_pks_chain_order'], [l.pk for l in levels])
     self.assertEqual(data['indicator_pks_for_level'], level_pks)
コード例 #7
0
 def test_has_a_sector_pk(self):
     sector = SectorFactory()
     data = get_indicator_data(program=RFProgramFactory(), sector=sector)
     self.assertEqual(data['sector_pk'], sector.pk)