Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.

Commit bd95526

Browse files
authored
proxy raw dict attributes in TerraformValueDict (#6)
1 parent 72f6d40 commit bd95526

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
# [1.1.0]
11+
12+
## Added
13+
14+
- proxy raw dict methods in `TerraformValueDict`
15+
1016
## [1.0.1]
1117

1218
## Changed
@@ -35,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3541
- remove the `teardown` method
3642
- unify the `plan` and `plan_out` methods
3743

38-
[Unreleased]: https://github.com/GoogleCloudPlatform/terraform-python-testing-helper/compare/v4.0.0...HEAD
44+
[Unreleased]: https://github.com/GoogleCloudPlatform/terraform-python-testing-helper/compare/v1.1.0...HEAD
45+
[1.1.0]: https://github.com/GoogleCloudPlatform/terraform-python-testing-helper/compare/v1.0.1...v1.1.0
3946
[1.0.1]: https://github.com/GoogleCloudPlatform/terraform-python-testing-helper/compare/v1.0.0...v1.0.1
4047
[1.0.0]: https://github.com/GoogleCloudPlatform/terraform-python-testing-helper/compare/v0.6.2...v1.0.0

test/test_value_dict.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"Test the Terraform value dict wrapper class."
16+
17+
import pytest
18+
import tftest
19+
20+
21+
_RAW = {'a': {'value': 1, 'sensitive': True}, 'b': {'value': 2}}
22+
23+
24+
@pytest.fixture
25+
def wrapper():
26+
return tftest.TerraformValueDict(_RAW)
27+
28+
29+
def test_getitem(wrapper):
30+
assert wrapper['a'] == 1
31+
32+
33+
def test_getitem_dict_attrs(wrapper):
34+
assert wrapper.keys() == _RAW.keys()

tftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import tempfile
3434
import weakref
3535

36-
__version__ = '1.0.1'
36+
__version__ = '1.1.0'
3737

3838
_LOGGER = logging.getLogger('tftest')
3939

@@ -116,6 +116,9 @@ def __init__(self, raw):
116116
# only matters for outputs
117117
self.sensitive = tuple(k for k, v in raw.items() if v.get('sensitive'))
118118

119+
def __getattr__(self, name):
120+
return getattr(self._raw, name)
121+
119122
def __getitem__(self, name):
120123
return self._raw[name].get('value')
121124

0 commit comments

Comments
 (0)