This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use deduced_required value for config.push
- Loading branch information
1 parent
29cc91b
commit 1b2f4a0
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ | |
from . import numbers | ||
from . import special_numbers | ||
from . import car | ||
from . import required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Copyright 2019 Equinor ASA and The Netherlands Organisation for | ||
Applied Scientific Research TNO. | ||
Licensed under the MIT license. | ||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the conditions stated in the LICENSE file in the project root for | ||
details. | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
""" | ||
|
||
|
||
from configsuite import MetaKeys as MK | ||
from configsuite import types | ||
|
||
|
||
def build_schema(): | ||
return { | ||
MK.Type: types.NamedDict, | ||
MK.Content: { | ||
"not_required": {MK.Type: types.Integer, MK.AllowNone: True}, | ||
"a_required_string": {MK.Type: types.String,}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Copyright 2019 Equinor ASA and The Netherlands Organisation for | ||
Applied Scientific Research TNO. | ||
Licensed under the MIT license. | ||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the conditions stated in the LICENSE file in the project root for | ||
details. | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
""" | ||
|
||
import unittest | ||
|
||
import configsuite | ||
|
||
from . import data | ||
|
||
|
||
class TestPush(unittest.TestCase): | ||
def assertEqualSnapshots(self, first, second): | ||
self.assertEqual(first.heroes, second.heroes) | ||
self.assertEqual(sorted(first.villains), sorted(second.villains)) | ||
|
||
def test_push_deduced_required(self): | ||
schema = data.required.build_schema() | ||
|
||
heroes = {"a_required_string": "a_string"} | ||
|
||
basic_config = configsuite.ConfigSuite(heroes, schema, deduce_required=True) | ||
self.assertTrue(basic_config.valid) | ||
|
||
basic_config = basic_config.push({"not_required": 10}) | ||
self.assertTrue(basic_config.valid) | ||
|
||
self.assertTrue(basic_config._deduce_required) |