コード例 #1
0
ファイル: test_admin.py プロジェクト: pmk01/EveryElection
 def test_invalid_source(self):
     og = OrganisationGeographyFactory()
     og.source = "unknown"
     og.save()
     self.assertEqual(len(OrganisationGeographyProblem.objects.all()), 1)
     problem = OrganisationGeographyProblem.objects.all()[0]
     self.assertFalse(problem.no_gss_code)
     self.assertFalse(problem.no_geography)
     self.assertTrue(problem.invalid_source)
     self.assertEqual("Boundary source is invalid", problem.problem_text)
コード例 #2
0
 def test_one_geography_with_gss(self):
     org = OrganisationFactory()
     geo = OrganisationGeographyFactory(organisation=org, gss='X01000001')
     self.assertEqual(geo, org.get_geography(date.today()))
     self.assertEqual(geo,
                      org.get_geography("doesn't even need to be a date"))
     self.assertEqual('https://mapit.mysociety.org/area/X01000001',
                      org.format_geography_link())
     geo.gss = ''
     geo.save()
     self.assertEqual(None, org.format_geography_link())
コード例 #3
0
 def test_save_organisationgeography_after_end(self):
     with self.assertRaises(ValidationError):
         OrganisationGeographyFactory(
             organisation=self.org,
             start_date=date(2001, 1, 1),
             end_date=date(2003, 1, 1),
         )
コード例 #4
0
ファイル: test_admin.py プロジェクト: pmk01/EveryElection
    def test_all_ok(self):
        org = OrganisationFactory()
        OrganisationDivisionSetFactory(organisation=org)
        OrganisationGeographyFactory(organisation=org)
        ElectedRoleFactory(organisation=org)

        self.assertEqual(len(OrganisationProblem.objects.all()), 0)
コード例 #5
0
 def test_import_org_geography(self):
     cmd = ConcreteOsniCommand()
     og = OrganisationGeographyFactory(organisation=OrganisationFactory(),
                                       geography=None,
                                       source="unknown")
     cmd.import_org_geography(og, fake_record)
     self.assertEqual(fake_record["geometry"], og.geography)
     self.assertEqual(cmd.source, og.source)
コード例 #6
0
 def test_save_organisationgeography_valid(self):
     try:
         OrganisationGeographyFactory(
             organisation=self.org,
             start_date=date(2001, 1, 1),
             end_date=date(2002, 1, 1),
         )
     except ValidationError:
         self.fail("ValidationError raised unexpectedly!")
コード例 #7
0
 def test_multiple_geographies(self):
     org = OrganisationFactory(start_date=date(2001, 1, 1), end_date=None)
     OrganisationGeographyFactory(organisation=org,
                                  gss='X01000001',
                                  start_date=None,
                                  end_date='2001-01-01')
     OrganisationGeographyFactory(organisation=org,
                                  gss='X01000002',
                                  start_date='2001-01-02',
                                  end_date='2002-01-01')
     OrganisationGeographyFactory(organisation=org,
                                  gss='X01000003',
                                  start_date='2002-01-02',
                                  end_date=None)
     self.assertEqual('X01000001', org.get_geography(date(2001, 1, 1)).gss)
     self.assertEqual('X01000002', org.get_geography(date(2001, 7, 20)).gss)
     self.assertEqual('X01000003', org.get_geography(date(2099, 1, 1)).gss)
     with self.assertRaises(ValueError):
         org.get_geography(date(1900, 1, 1))  # before the org start date
コード例 #8
0
ファイル: test_admin.py プロジェクト: pmk01/EveryElection
    def test_no_electedrole(self):
        org = OrganisationFactory()
        OrganisationDivisionSetFactory(organisation=org)
        OrganisationGeographyFactory(organisation=org)

        self.assertEqual(len(OrganisationProblem.objects.all()), 1)
        problem = OrganisationProblem.objects.all()[0]
        self.assertFalse(problem.no_geography)
        self.assertFalse(problem.no_divisionset)
        self.assertTrue(problem.no_electedrole)
        self.assertEqual("No associated ElectedRole", problem.problem_text)
コード例 #9
0
ファイル: test_admin.py プロジェクト: pmk01/EveryElection
 def test_all_broken(self):
     og = OrganisationGeographyFactory()
     og.source = ""
     og.gss = ""
     og.geography = None
     og.save()
     self.assertEqual(len(OrganisationGeographyProblem.objects.all()), 1)
     problem = OrganisationGeographyProblem.objects.all()[0]
     self.assertTrue(problem.no_gss_code)
     self.assertTrue(problem.no_geography)
     self.assertTrue(problem.invalid_source)
     self.assertEqual("Geography field is NULL", problem.problem_text)
コード例 #10
0
ファイル: test_admin.py プロジェクト: pmk01/EveryElection
 def test_no_gss_code(self):
     og = OrganisationGeographyFactory()
     og.source = "this is totally fine"
     og.gss = ""
     og.save()
     self.assertEqual(len(OrganisationGeographyProblem.objects.all()), 1)
     problem = OrganisationGeographyProblem.objects.all()[0]
     self.assertTrue(problem.no_gss_code)
     self.assertFalse(problem.no_geography)
     self.assertFalse(problem.invalid_source)
     self.assertEqual("No GSS code", problem.problem_text)
コード例 #11
0
ファイル: test_admin.py プロジェクト: chris48s/EveryElection
 def test_no_geography(self):
     og = OrganisationGeographyFactory()
     og.source = 'this is totally fine'
     og.geography = None
     og.save()
     self.assertEqual(len(OrganisationGeographyProblem.objects.all()), 1)
     problem = OrganisationGeographyProblem.objects.all()[0]
     self.assertFalse(problem.no_gss_code)
     self.assertTrue(problem.no_geography)
     self.assertFalse(problem.invalid_source)
     self.assertEqual('Geography field is NULL', problem.problem_text)
コード例 #12
0
    def setUp(self):
        super().setUp()
        OrganisationGeographyFactory(organisation=OrganisationFactory(
            official_identifier='TEST1',
            official_name='Foo & Bar District Council',
            organisation_type="local-authority",
            start_date=date(2016, 10, 1),
            end_date=date(2017, 10, 1)))
        OrganisationFactory(official_identifier='TEST1',
                            official_name='Bar with Foo District Council',
                            organisation_type="local-authority",
                            start_date=date(2017, 10, 2),
                            end_date=None)

        OrganisationFactory(official_identifier='TEST2',
                            official_name='Baz District Council',
                            organisation_type="local-authority",
                            start_date=date(2016, 10, 1),
                            end_date=date(2017, 10, 1))
コード例 #13
0
 def test_one_geography_no_gss(self):
     org = OrganisationFactory()
     geo = OrganisationGeographyFactory(organisation=org, gss='')
     self.assertEqual(geo, org.get_geography(date.today()))
     self.assertEqual(None, org.format_geography_link())
コード例 #14
0
 def test_save_organisationgeography_before_start(self):
     with self.assertRaises(ValidationError):
         OrganisationGeographyFactory(
             organisation=self.org,
             start_date=date(2000, 1, 1),
         )
コード例 #15
0
ファイル: test_admin.py プロジェクト: pmk01/EveryElection
 def test_all_ok(self):
     og = OrganisationGeographyFactory()
     og.source = "this is totally fine"
     og.save()
     self.assertEqual(len(OrganisationGeographyProblem.objects.all()), 0)