civics-cdf-validator 1.56.dev1__py3-none-any.whl → 1.56.dev3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -633,18 +633,6 @@ class GpUnitOcdId(base.BaseRule):
633
633
  )
634
634
 
635
635
 
636
- # TODO(b/337001513): Remove this once the new rule is rolled out everywhere and
637
- # no feeds have this in their disabled rules anymore.
638
- class ElectoralDistrictOcdId(base.BaseRule):
639
- """All GpUnits MUST have a valid OCD ID."""
640
-
641
- def elements(self):
642
- return ["ReportingUnit"]
643
-
644
- def check(self, element):
645
- pass
646
-
647
-
648
636
  class DuplicatedGpUnitOcdId(base.BaseRule):
649
637
  """2 GpUnits should not have same OCD ID."""
650
638
 
@@ -4341,7 +4329,7 @@ class SourceDirPathMustBeSetAfterInitialDeliveryDate(base.BaseRule):
4341
4329
  )
4342
4330
 
4343
4331
 
4344
- class OfficeHolderSubFeedDatesAreSequential(base.DateRule):
4332
+ class OfficeholderSubFeedDatesAreSequential(base.DateRule):
4345
4333
  """Dates in an OfficeHolderSubFeed element should be sequential."""
4346
4334
 
4347
4335
  def elements(self):
@@ -4732,6 +4720,47 @@ class NoExtraElectionReportCollections(base.BaseRule):
4732
4720
  )
4733
4721
 
4734
4722
 
4723
+ class FeedElementsShouldHaveSubElementsBasedOnType(base.BaseRule):
4724
+ """Feeds should have certain elements based on feed type.
4725
+
4726
+ For example, Feeds of type officeHolder should have an OfficeHolderSubFeed,
4727
+ similarly pre-election and election-results feeds should have an
4728
+ ElectionEventCollection. In the case of an ElectionEventCollection, at least
4729
+ one ElectionEvent element should be present.
4730
+ """
4731
+
4732
+ def elements(self):
4733
+ return ["Feed"]
4734
+
4735
+ def check(self, element):
4736
+ feed_type = element.find("FeedType")
4737
+ feed_id = element.find("FeedId").text
4738
+
4739
+ if not element_has_text(feed_type):
4740
+ return
4741
+
4742
+ feed_type = feed_type.text
4743
+ if feed_type == "officeholder":
4744
+ if element.find("OfficeholderSubFeed") is None:
4745
+ raise loggers.ElectionError.from_message(
4746
+ "OfficeholderSubFeed should exist for %s feed %s."
4747
+ % (feed_type, feed_id)
4748
+ )
4749
+ elif feed_type == "pre-election" or feed_type == "election-results":
4750
+ if element.find("ElectionEventCollection") is None:
4751
+ raise loggers.ElectionError.from_message(
4752
+ "ElectionEventCollection should exist for %s feed %s."
4753
+ % (feed_type, feed_id)
4754
+ )
4755
+ if not element.find("ElectionEventCollection").findall(
4756
+ "ElectionEvent"
4757
+ ):
4758
+ raise loggers.ElectionError.from_message(
4759
+ "ElectionEventCollection should have at least one ElectionEvent"
4760
+ " for %s feed %s." % (feed_type, feed_id)
4761
+ )
4762
+
4763
+
4735
4764
  class RuleSet(enum.Enum):
4736
4765
  """Names for sets of rules used to validate a particular feed type."""
4737
4766
 
@@ -4826,7 +4855,6 @@ ELECTION_RULES = COMMON_RULES + (
4826
4855
  ElectionStartDates,
4827
4856
  ElectionTypesAndCandidateContestTypesAreCompatible,
4828
4857
  ElectionTypesAreCompatible,
4829
- ElectoralDistrictOcdId,
4830
4858
  FullTextMaxLength,
4831
4859
  FullTextOrBallotText,
4832
4860
  GpUnitsHaveSingleRoot,
@@ -4888,12 +4916,13 @@ METADATA_RULES = (
4888
4916
  # go/keep-sorted start
4889
4917
  ElectionEventDatesAreSequential,
4890
4918
  Encoding,
4919
+ FeedElementsShouldHaveSubElementsBasedOnType,
4891
4920
  FeedHasValidCountryCode,
4892
4921
  FeedIdsAreUnique,
4893
4922
  FeedInactiveDateIsLatestDate,
4894
4923
  FeedInactiveDateSetForNonEvergreenFeed,
4895
4924
  FeedTypeHasValidFeedLongevity,
4896
- OfficeHolderSubFeedDatesAreSequential,
4925
+ OfficeholderSubFeedDatesAreSequential,
4897
4926
  OptionalAndEmpty,
4898
4927
  Schema,
4899
4928
  SourceDirPathMustBeSetAfterInitialDeliveryDate,
@@ -5,4 +5,4 @@ No dependencies should be added to this module.
5
5
  See https://packaging.python.org/guides/single-sourcing-package-version/
6
6
  """
7
7
 
8
- __version__ = '1.56.dev1'
8
+ __version__ = '1.56.dev3'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.56.dev1
3
+ Version: 1.56.dev3
4
4
  Summary: Checks if an election feed follows best practices
5
5
  Home-page: https://github.com/google/civics_cdf_validator
6
6
  Author: Google Civics
@@ -3,13 +3,13 @@ civics_cdf_validator/base.py,sha256=5zntjAdAA-bdwYOOStFgUle9LGX_ccelS--thMhUG9A,
3
3
  civics_cdf_validator/gpunit_rules.py,sha256=Cg-qlOeVKTCQ5qUKYSxbVrrh3tdLt1X5Eg-7uyyR_SY,9487
4
4
  civics_cdf_validator/loggers.py,sha256=ZfWFd9yskcd2-qb83EPz7eqa1iGO8BRFMtDZeE1hofA,6921
5
5
  civics_cdf_validator/office_utils.py,sha256=aFxcFQZF2oBn0gPXt_kv1LxHGvwzABScT8X5yaYtVLw,2705
6
- civics_cdf_validator/rules.py,sha256=HeV9gjKBXkvwG_zDlI6XlYvuHegZBqRDkvrBJjpcxBA,164276
6
+ civics_cdf_validator/rules.py,sha256=ioYMDJ8TymWyLVLtLXjOadfFXa78_Kk1wThUmbI452M,165458
7
7
  civics_cdf_validator/stats.py,sha256=YNqv3Khkt_hJxCIunFBRSl23oXqu5gNjCmWMHFbAcSU,3819
8
8
  civics_cdf_validator/validator.py,sha256=2nwlFfQ9AmpTaO5n5ekaO845Rm0JPjNF-Il6FJW_50k,12678
9
- civics_cdf_validator/version.py,sha256=K0XaAKcTljLmR6-BPZvcbojWL3yCgsRN76Zo7AAoogs,188
10
- civics_cdf_validator-1.56.dev1.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
- civics_cdf_validator-1.56.dev1.dist-info/METADATA,sha256=v9osN_mvpPXGm-932ULK5v0Zxu2L_zaVZ3YNzeURW_0,1218
12
- civics_cdf_validator-1.56.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- civics_cdf_validator-1.56.dev1.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
- civics_cdf_validator-1.56.dev1.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
- civics_cdf_validator-1.56.dev1.dist-info/RECORD,,
9
+ civics_cdf_validator/version.py,sha256=uG573yGW1ViQ6oaGoYlzWfXyjZIA3_2envRTa6rcHkY,188
10
+ civics_cdf_validator-1.56.dev3.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
+ civics_cdf_validator-1.56.dev3.dist-info/METADATA,sha256=NxouFx5Fm7HHHrFpmxy5bmjDHWX5Yc6ASVr9OeYmpzo,1218
12
+ civics_cdf_validator-1.56.dev3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
+ civics_cdf_validator-1.56.dev3.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
+ civics_cdf_validator-1.56.dev3.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
+ civics_cdf_validator-1.56.dev3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5