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 c4df2a1
Showing
2 changed files
with
46 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
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.hero.build_schema() | ||
|
||
heroes = { | ||
"heroes": [ | ||
{"name": "Batman", "strength": 10}, | ||
{"name": "Flash", "strength": 12}, | ||
{"name": "Dirk Gently", "strength": 7}, | ||
] | ||
} | ||
|
||
villains = {"villains": {"Eobard Thawne": 11, "Lux": 3}} | ||
|
||
hero_config = configsuite.ConfigSuite(heroes, schema, deduce_required=True) | ||
self.assertTrue(hero_config.valid) | ||
hero_villains_config = hero_config.push(villains) | ||
self.assertTrue(hero_villains_config.valid) | ||
|
||
combined = { | ||
"heroes": [ | ||
{"name": "Batman", "strength": 10}, | ||
{"name": "Flash", "strength": 12}, | ||
{"name": "Dirk Gently", "strength": 7}, | ||
], | ||
"villains": {"Eobard Thawne": 11, "Lux": 3}, | ||
} | ||
combined_config = configsuite.ConfigSuite(combined, schema) | ||
self.assertTrue(combined_config.valid) | ||
|
||
self.assertEqualSnapshots( | ||
combined_config.snapshot, hero_villains_config.snapshot | ||
) |