civics-cdf-validator 1.56.dev2__py3-none-any.whl → 1.56.dev4__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.
@@ -4329,7 +4329,7 @@ class SourceDirPathMustBeSetAfterInitialDeliveryDate(base.BaseRule):
4329
4329
  )
4330
4330
 
4331
4331
 
4332
- class OfficeHolderSubFeedDatesAreSequential(base.DateRule):
4332
+ class OfficeholderSubFeedDatesAreSequential(base.DateRule):
4333
4333
  """Dates in an OfficeHolderSubFeed element should be sequential."""
4334
4334
 
4335
4335
  def elements(self):
@@ -4720,6 +4720,47 @@ class NoExtraElectionReportCollections(base.BaseRule):
4720
4720
  )
4721
4721
 
4722
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
+
4723
4764
  class RuleSet(enum.Enum):
4724
4765
  """Names for sets of rules used to validate a particular feed type."""
4725
4766
 
@@ -4875,12 +4916,13 @@ METADATA_RULES = (
4875
4916
  # go/keep-sorted start
4876
4917
  ElectionEventDatesAreSequential,
4877
4918
  Encoding,
4919
+ FeedElementsShouldHaveSubElementsBasedOnType,
4878
4920
  FeedHasValidCountryCode,
4879
4921
  FeedIdsAreUnique,
4880
4922
  FeedInactiveDateIsLatestDate,
4881
4923
  FeedInactiveDateSetForNonEvergreenFeed,
4882
4924
  FeedTypeHasValidFeedLongevity,
4883
- OfficeHolderSubFeedDatesAreSequential,
4925
+ OfficeholderSubFeedDatesAreSequential,
4884
4926
  OptionalAndEmpty,
4885
4927
  Schema,
4886
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.dev2'
8
+ __version__ = '1.56.dev4'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: civics_cdf_validator
3
- Version: 1.56.dev2
3
+ Version: 1.56.dev4
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=ujrA2j1Iy9KnXecsdMVW_5Sx6OzJyANALkjlsMeshws,163931
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=Hn0YCjulJVsEgbNuLfeYPBEoMigpW17LEq8SG-VEpc4,188
10
- civics_cdf_validator-1.56.dev2.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
- civics_cdf_validator-1.56.dev2.dist-info/METADATA,sha256=EYVlVch5BzRYfpmAJ-cqQD1uJyYzcsDOyGQ06LxyT38,1218
12
- civics_cdf_validator-1.56.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- civics_cdf_validator-1.56.dev2.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
- civics_cdf_validator-1.56.dev2.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
- civics_cdf_validator-1.56.dev2.dist-info/RECORD,,
9
+ civics_cdf_validator/version.py,sha256=IBKDbTIjfcOB-bAnUouzMf0-Mh5656Dqo5OfGJYcKL4,188
10
+ civics_cdf_validator-1.56.dev4.dist-info/licenses/LICENSE-2.0.txt,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
11
+ civics_cdf_validator-1.56.dev4.dist-info/METADATA,sha256=oGNOZ3PLxlUpSknWKkR06LwvBec1h6SYdzv_0p3om8k,1218
12
+ civics_cdf_validator-1.56.dev4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
13
+ civics_cdf_validator-1.56.dev4.dist-info/entry_points.txt,sha256=QibgvtMOocwDi7fQ1emgMJ2lIlI41sW0__KIQdnVn90,77
14
+ civics_cdf_validator-1.56.dev4.dist-info/top_level.txt,sha256=PYT5Eclxbop5o6DJIcgs4IeU6Ds5jqyftjoFbgkkJYo,21
15
+ civics_cdf_validator-1.56.dev4.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