コード例 #1
0
def test_get_overrides_file_not_found(base):
    path = base / "overrides.json"
    try:
        path.unlink()
    except FileNotFoundError:
        pass
    assert get_overrides(path) == EMPTY_OVERRIDE
コード例 #2
0
def test_get_overrides_good_path(base):
    overrides = empty_override()
    overrides["CREATE"]["/foo/bar"] = {}

    path = base / "overrides.json"
    with path.open("w", encoding="utf-8") as f:
        json.dump(overrides, f)
    assert get_overrides(base) == {"CREATE": {("foo", "bar"): {}}}
コード例 #3
0
def test_get_overrides_invalid_pointer_skipped(base):
    overrides = empty_override()
    overrides["CREATE"]["#/foo/bar"] = None

    path = base / "overrides.json"
    with path.open("w", encoding="utf-8") as f:
        json.dump(overrides, f)
    assert get_overrides(base) == EMPTY_OVERRIDE
コード例 #4
0
def test_get_overrides_file_not_found(base):
    path = base / "overrides.json"
    try:
        path.unlink()
    except FileNotFoundError:
        pass
    assert get_overrides(path, DEFAULT_REGION, "",
                         None) == EMPTY_RESOURCE_OVERRIDE
コード例 #5
0
def test_get_overrides_with_jinja(base, overrides_string,
                                  list_exports_return_value,
                                  expected_overrides):
    mock_cfn_client = Mock(spec=["get_paginator"])
    mock_paginator = Mock(spec=["paginate"])
    mock_cfn_client.get_paginator.return_value = mock_paginator
    mock_paginator.paginate.return_value = list_exports_return_value
    patch_sdk = patch("rpdk.core.test.create_sdk_session", autospec=True)

    path = base / "overrides.json"
    with path.open("w", encoding="utf-8") as f:
        f.write(overrides_string)
    with patch_sdk as mock_sdk:
        mock_sdk.return_value.client.side_effect = [mock_cfn_client, Mock()]
        result = get_overrides(base, DEFAULT_REGION, None)

    assert result == expected_overrides
コード例 #6
0
def test_get_overrides_empty_overrides(base):
    path = base / "overrides.json"
    with path.open("w", encoding="utf-8") as f:
        json.dump(EMPTY_OVERRIDE, f)
    assert get_overrides(base) == EMPTY_OVERRIDE
コード例 #7
0
def test_get_overrides_invalid_file(base):
    path = base / "overrides.json"
    path.write_text("{}")
    assert get_overrides(base) == EMPTY_OVERRIDE
コード例 #8
0
def test_get_overrides_no_root():
    assert get_overrides(None) == EMPTY_OVERRIDE
コード例 #9
0
def test_get_overrides_no_root():
    assert get_overrides(None, DEFAULT_REGION, "", None) == EMPTY_OVERRIDE
コード例 #10
0
def test_get_overrides_empty_overrides(base):
    path = base / "overrides.json"
    with path.open("w", encoding="utf-8") as f:
        json.dump(EMPTY_RESOURCE_OVERRIDE, f)
    assert get_overrides(base, DEFAULT_REGION, "",
                         None) == EMPTY_RESOURCE_OVERRIDE
コード例 #11
0
def test_get_overrides_invalid_file(base):
    path = base / "overrides.json"
    path.write_text("{}")
    assert get_overrides(base, DEFAULT_REGION, "",
                         None) == EMPTY_RESOURCE_OVERRIDE