def setUpTestData(cls): cls.country_one = CountryFactory() cls.country_two = CountryFactory() SchoolFactory(country=cls.country_one, location__country=cls.country_one) SchoolFactory(country=cls.country_one, location__country=cls.country_one)
def setUpTestData(cls): cls.country_one = CountryFactory() cls.country_two = CountryFactory() cls.country_one_stats_number = random.SystemRandom().randint(a=5, b=25) for _i in range(cls.country_one_stats_number): CountryDailyStatusFactory(country=cls.country_one) CountryDailyStatusFactory(country=cls.country_two)
def test_clear_data_function(self): country = CountryFactory() country.last_weekly_status.update_country_status_to_joined() [SchoolFactory(country=country) for _ in range(3)] self.assertEqual(country.schools.count(), 3) self.assertEqual(country.last_weekly_status.integration_status, CountryWeeklyStatus.JOINED) country._clear_data_country() self.assertEqual(country.schools.count(), 0) self.assertEqual(country.last_weekly_status.integration_status, CountryWeeklyStatus.COUNTRY_CREATED)
def setUpTestData(cls): cls.country = CountryFactory() cls.school = SchoolFactory(country=cls.country) RealTimeConnectivityFactory(school=cls.school, connectivity_speed=4000000) RealTimeConnectivityFactory(school=cls.school, connectivity_speed=6000000)
def setUpTestData(cls): cls.country = CountryFactory() cls.school_one = SchoolFactory(country=cls.country, location__country=cls.country) cls.school_two = SchoolFactory(country=cls.country, location__country=cls.country) cls.school_three = SchoolFactory(country=cls.country, location__country=cls.country) cls.school_weekly_one = SchoolWeeklyStatusFactory( school=cls.school_one, connectivity=True, connectivity_speed=3 * (10 ** 6), coverage_availability=True, coverage_type='3g', ) cls.school_weekly_two = SchoolWeeklyStatusFactory( school=cls.school_one, connectivity=False, connectivity_speed=None, coverage_availability=False, coverage_type='no', ) cls.school_weekly_three = SchoolWeeklyStatusFactory( school=cls.school_one, connectivity=None, connectivity_speed=None, coverage_availability=None, coverage_type='unknown', ) cls.school_one.last_weekly_status = cls.school_weekly_one cls.school_one.save() cls.school_two.last_weekly_status = cls.school_weekly_two cls.school_two.save() cls.school_three.last_weekly_status = cls.school_weekly_three cls.school_three.save()
def test_geometry_optimization_small_country(self): with open('proco/locations/tests/data/anquila.json') as geometry_file: country = CountryFactory(geometry=geometry_file.read()) self.assertFalse(country.geometry_simplified.empty) self.assertNotEqual(country.geometry_simplified.num_points, country.geometry.num_points)
def test_empty_countries_hidden(self): CountryFactory(geometry=GEOSGeometry( '{"type": "MultiPolygon", "coordinates": []}')) self._test_list( user=None, expected_objects=[self.country_one, self.country_two], )
def test_empty_countries_hidden(self): CountryFactory(geometry=GEOSGeometry( '{"type": "MultiPolygon", "coordinates": []}')) response = self.forced_auth_req('get', reverse(self.base_view)) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertCountEqual([r['id'] for r in response.data], [self.country_one.id, self.country_two.id])
def setUpTestData(cls): super().setUpTestData() with open( os.path.join('proco', 'connection_statistics', 'tests', 'data', 'brazil_example.json')) as example: cls.example_data = json.load(example) cls.country = CountryFactory(code='BR')
def setUpTestData(cls): cls.country_one = CountryFactory() cls.school_one = SchoolFactory(country=cls.country_one, location__country=cls.country_one, geopoint=None) cls.school_two = SchoolFactory(country=cls.country_one, location__country=cls.country_one) SchoolWeeklyStatusFactory(school=cls.school_one, connectivity=True) SchoolWeeklyStatusFactory(school=cls.school_two, connectivity=False) CountryWeeklyStatusFactory( country=cls.country_one, integration_status=CountryWeeklyStatus.REALTIME_MAPPED, year=datetime.now().year + 1, schools_connectivity_no=1) cls.cws = CountryWeeklyStatusFactory( integration_status=CountryWeeklyStatus.STATIC_MAPPED, schools_connectivity_no=0, year=datetime.now().year + 2)
def setUpTestData(cls): cls.country_one = CountryFactory() cls.country_two = CountryFactory() cls.stat_one = CountryWeeklyStatusFactory(country=cls.country_one) cls.stat_two = CountryWeeklyStatusFactory(country=cls.country_two)
def test_geometry_null(self): country = CountryFactory(geometry=None) self.assertIsNone(country.geometry) self.assertIsNone(country.geometry_simplified)
def test_optimization_for_empty_geometry(self): country = CountryFactory(geometry=GEOSGeometry( '{"type": "MultiPolygon", "coordinates": []}')) self.assertTrue(country.geometry.empty) self.assertTrue(country.geometry_simplified.empty)