Skip to content

Commit

Permalink
Merge pull request #32 from hCaptcha/josiah-allow-simple
Browse files Browse the repository at this point in the history
allow unnested floats for min_difficulty
  • Loading branch information
josiah-im committed Mar 10, 2020
2 parents e023184 + 31028a2 commit b679ced
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion basemodels/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def validate_groundtruth(self, data, value):
# Configuration id -- XXX LEGACY
confcalc_configuration_id = StringType(required=False)

restricted_audience = DictType(ListType(DictType(DictType(FloatType))))
restricted_audience = DictType(UnionType([FloatType, ListType(DictType(DictType(FloatType)))]))

def validate_taskdata_uri(self, data, value):
if data.get('taskdata') and len(data.get('taskdata')) > 0 and data.get('taskdata_uri'):
Expand Down
4 changes: 3 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def test_restricted_audience(self):
"minimum_client_confidence": {
"score": 0.9
}
}]
}],
"min_difficulty": 2,
}
manifest.validate()
self.assertTrue("restricted_audience" in manifest.to_primitive())
Expand All @@ -231,6 +232,7 @@ def test_restricted_audience(self):
self.assertEqual(
0.9,
manifest.to_primitive()["restricted_audience"]["lang"][0]["en-us"]["score"])
self.assertEqual(2, manifest.to_primitive()["restricted_audience"]["min_difficulty"])

def test_realistic_multi_challenge_example(self):
""" validates a realistic multi_challenge manifest """
Expand Down

0 comments on commit b679ced

Please sign in to comment.