cloud-radar 0.14.1a2__tar.gz → 0.15.0a0__tar.gz

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.
Files changed (18) hide show
  1. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/PKG-INFO +4 -2
  2. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/README.md +3 -1
  3. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/pyproject.toml +1 -1
  4. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_output.py +5 -4
  5. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/functions.py +13 -4
  6. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/LICENSE.txt +0 -0
  7. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/__init__.py +0 -0
  8. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/__init__.py +0 -0
  9. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/e2e/__init__.py +0 -0
  10. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/e2e/_stack.py +0 -0
  11. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/__init__.py +0 -0
  12. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_condition.py +0 -0
  13. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_hooks.py +0 -0
  14. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_parameter.py +0 -0
  15. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_resource.py +0 -0
  16. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_stack.py +0 -0
  17. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/_template.py +0 -0
  18. {cloud_radar-0.14.1a2 → cloud_radar-0.15.0a0}/src/cloud_radar/cf/unit/test__template.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cloud-radar
3
- Version: 0.14.1a2
3
+ Version: 0.15.0a0
4
4
  Summary: Run functional tests on cloudformation stacks.
5
5
  License: Apache-2.0
6
6
  Keywords: aws,cloudformation,cloud-radar,testing,taskcat,cloud,radar
@@ -239,7 +239,7 @@ dynamic_references = {
239
239
  template = Template(template_content, dynamic_references=dynamic_references)
240
240
  ```
241
241
 
242
- There are cases where the default behaviour of our `GetAtt` implementation may not be sufficient and you need a more accurate returned value. When unit testing there are no real AWS resources created, and cloud-radar does not attempt to realistically generate attribute values - a string is always returned. This works good enough most of the time, but there are some cases where if you are attempting to apply intrinsic functions against the attribute value it needs to be more correct. When this occurs, you can add Metadata to the template to provide test values to use.
242
+ There are cases where the default behaviour of our `Ref` and `GetAtt` implementations may not be sufficient and you need a more accurate returned value. When unit testing there are no real AWS resources created, and cloud-radar does not attempt to realistically generate attribute values - a string is always returned. For `Ref` this is the logical resource name, for `GetAtt` this is `<logical resource name>.<attribute name>`. This works good enough most of the time, but there are some cases where if you are attempting to apply intrinsic functions against these value it needs to be more correct. When this occurs, you can add Metadata to the template to provide test values to use.
243
243
 
244
244
  ```
245
245
  Resources:
@@ -247,6 +247,7 @@ Resources:
247
247
  Type: AWS::MediaPackageV2::Channel
248
248
  Metadata:
249
249
  Cloud-Radar:
250
+ ref: arn:aws:mediapackagev2:region:AccountId:ChannelGroup/ChannelGroupName/Channel/ChannelName
250
251
  attribute-values:
251
252
  # Default behaviour of a string is not good enough here, the attribute value is expected to be a List.
252
253
  IngestEndpointUrls:
@@ -256,6 +257,7 @@ Resources:
256
257
  ChannelGroupName: dev_video_1
257
258
  ChannelName: !Sub ${AWS::StackName}-MediaPackageChannel
258
259
  ```
260
+ If you are unable to modify the template itself, it is also possible to inject this metadata as part of the unit test. See [this test case](./tests/test_cf/test_unit/test_functions_ref.py) for an example.
259
261
 
260
262
  A real unit testing example using Pytest can be seen [here](./tests/test_cf/test_examples/test_unit.py)
261
263
 
@@ -211,7 +211,7 @@ dynamic_references = {
211
211
  template = Template(template_content, dynamic_references=dynamic_references)
212
212
  ```
213
213
 
214
- There are cases where the default behaviour of our `GetAtt` implementation may not be sufficient and you need a more accurate returned value. When unit testing there are no real AWS resources created, and cloud-radar does not attempt to realistically generate attribute values - a string is always returned. This works good enough most of the time, but there are some cases where if you are attempting to apply intrinsic functions against the attribute value it needs to be more correct. When this occurs, you can add Metadata to the template to provide test values to use.
214
+ There are cases where the default behaviour of our `Ref` and `GetAtt` implementations may not be sufficient and you need a more accurate returned value. When unit testing there are no real AWS resources created, and cloud-radar does not attempt to realistically generate attribute values - a string is always returned. For `Ref` this is the logical resource name, for `GetAtt` this is `<logical resource name>.<attribute name>`. This works good enough most of the time, but there are some cases where if you are attempting to apply intrinsic functions against these value it needs to be more correct. When this occurs, you can add Metadata to the template to provide test values to use.
215
215
 
216
216
  ```
217
217
  Resources:
@@ -219,6 +219,7 @@ Resources:
219
219
  Type: AWS::MediaPackageV2::Channel
220
220
  Metadata:
221
221
  Cloud-Radar:
222
+ ref: arn:aws:mediapackagev2:region:AccountId:ChannelGroup/ChannelGroupName/Channel/ChannelName
222
223
  attribute-values:
223
224
  # Default behaviour of a string is not good enough here, the attribute value is expected to be a List.
224
225
  IngestEndpointUrls:
@@ -228,6 +229,7 @@ Resources:
228
229
  ChannelGroupName: dev_video_1
229
230
  ChannelName: !Sub ${AWS::StackName}-MediaPackageChannel
230
231
  ```
232
+ If you are unable to modify the template itself, it is also possible to inject this metadata as part of the unit test. See [this test case](./tests/test_cf/test_unit/test_functions_ref.py) for an example.
231
233
 
232
234
  A real unit testing example using Pytest can be seen [here](./tests/test_cf/test_examples/test_unit.py)
233
235
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cloud-radar"
3
- version = "0.14.1a2"
3
+ version = "0.15.0a0"
4
4
  description = "Run functional tests on cloudformation stacks."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -27,11 +27,12 @@ class Output(UserDict):
27
27
  Args:
28
28
  value (Any): The value to compare the output value to.
29
29
  """
30
- acutal_value = self.get_value()
30
+ actual_value = self.get_value()
31
31
 
32
- assert (
33
- value == acutal_value
34
- ), f"Output '{self.name}' actual value did not match input value."
32
+ assert value == actual_value, (
33
+ f"Output '{self.name}' actual value ({actual_value}) did not match"
34
+ f" input value ({value})."
35
+ )
35
36
 
36
37
  def has_export(self):
37
38
  """Check if the output has an export."""
@@ -459,14 +459,17 @@ def get_att(template: "Template", values: Any) -> str:
459
459
  # Check if there is a value in the resource Metadata for this attribute.
460
460
  # If the attribute requested is in the metadata, return it.
461
461
  # Otherwise use the string value of "{resource_name}.{att_name}"
462
-
463
- metadata = resource.get("Metadata", {})
464
- cloud_radar_metadata = metadata.get("Cloud-Radar", {})
462
+ cloud_radar_metadata = _get_cloud_radar_metadata(resource)
465
463
  attribute_values = cloud_radar_metadata.get("attribute-values", {})
466
464
 
467
465
  return attribute_values.get(att_name, f"{resource_name}.{att_name}")
468
466
 
469
467
 
468
+ def _get_cloud_radar_metadata(resource) -> dict:
469
+ metadata = resource.get("Metadata", {})
470
+ return metadata.get("Cloud-Radar", {})
471
+
472
+
470
473
  def get_azs(_t: "Template", region: Any) -> List[str]:
471
474
  """Solves AWS GetAZs intrinsic function.
472
475
 
@@ -857,7 +860,13 @@ def ref(template: "Template", var_name: str) -> Any:
857
860
  return param_value
858
861
 
859
862
  if var_name in template.template["Resources"]:
860
- return var_name
863
+ # Check if there is a value in the resource Metadata for this reference.
864
+ # If the ref requested is in the metadata, return it.
865
+ # Otherwise use the string value of the logical resource name
866
+ cloud_radar_metadata = _get_cloud_radar_metadata(
867
+ template.template["Resources"][var_name]
868
+ )
869
+ return cloud_radar_metadata.get("ref", var_name)
861
870
 
862
871
  raise Exception(f"Fn::Ref - {var_name} is not a valid Resource or Parameter.")
863
872