qontract-reconcile 0.10.1rc763__py3-none-any.whl → 0.10.1rc765__py3-none-any.whl

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 (41) hide show
  1. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/METADATA +1 -1
  2. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/RECORD +27 -31
  3. reconcile/external_resources/aws.py +85 -0
  4. reconcile/external_resources/factories.py +133 -0
  5. reconcile/external_resources/integration.py +95 -0
  6. reconcile/external_resources/manager.py +350 -0
  7. reconcile/external_resources/meta.py +4 -0
  8. reconcile/external_resources/metrics.py +20 -0
  9. reconcile/external_resources/model.py +244 -0
  10. reconcile/external_resources/reconciler.py +249 -0
  11. reconcile/external_resources/secrets_sync.py +229 -0
  12. reconcile/external_resources/state.py +246 -0
  13. reconcile/saas_auto_promotions_manager/meta.py +1 -1
  14. reconcile/saas_auto_promotions_manager/subscriber.py +52 -2
  15. reconcile/saas_auto_promotions_manager/utils/saas_files_inventory.py +4 -0
  16. reconcile/test/saas_auto_promotions_manager/conftest.py +63 -0
  17. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/conftest.py +0 -37
  18. reconcile/test/saas_auto_promotions_manager/merge_request_manager/merge_request_manager/test_desired_state.py +20 -14
  19. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/conftest.py +0 -43
  20. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_multiple_namespaces.py +4 -11
  21. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_namespace.py +12 -19
  22. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_content_single_target.py +6 -12
  23. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/test_json_path_selector.py +8 -15
  24. reconcile/test/saas_auto_promotions_manager/merge_request_manager/renderer/data_keys.py +0 -4
  25. reconcile/test/saas_auto_promotions_manager/subscriber/conftest.py +0 -89
  26. reconcile/test/saas_auto_promotions_manager/subscriber/data_keys.py +0 -11
  27. reconcile/test/saas_auto_promotions_manager/subscriber/test_content_hash.py +0 -130
  28. reconcile/test/saas_auto_promotions_manager/subscriber/test_diff.py +0 -161
  29. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_channels_config_hash.py +0 -218
  30. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_channels_moving_ref.py +0 -216
  31. reconcile/test/saas_auto_promotions_manager/subscriber/test_multiple_publishers_moving_ref.py +0 -129
  32. reconcile/test/saas_auto_promotions_manager/subscriber/test_single_channel_with_single_publisher.py +0 -330
  33. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/__init__.py +0 -0
  34. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_multiple_publishers_for_single_channel.py +0 -68
  35. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_use_target_config_hash.py +0 -62
  36. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_with_auto_promote.py +0 -73
  37. reconcile/test/saas_auto_promotions_manager/utils/saas_files_inventory/test_saas_files_without_auto_promote.py +0 -64
  38. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/WHEEL +0 -0
  39. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/entry_points.txt +0 -0
  40. {qontract_reconcile-0.10.1rc763.dist-info → qontract_reconcile-0.10.1rc765.dist-info}/top_level.txt +0 -0
  41. /reconcile/{test/saas_auto_promotions_manager/subscriber → external_resources}/__init__.py +0 -0
@@ -11,29 +11,22 @@ from reconcile.saas_auto_promotions_manager.subscriber import (
11
11
  Subscriber,
12
12
  )
13
13
 
14
- from .data_keys import (
15
- CHANNELS,
16
- CONFIG_HASHES,
17
- NAMESPACE,
18
- REF,
19
- )
20
-
21
14
 
22
15
  def test_content_single_namespace(
23
16
  file_contents: Callable[[str], tuple[str, str]],
24
17
  subscriber_builder: Callable[[Mapping], Subscriber],
25
18
  ):
26
19
  subscriber = subscriber_builder({
27
- NAMESPACE: {"path": "/some/namespace.yml"},
28
- REF: "new_sha",
29
- CONFIG_HASHES: [
20
+ "NAMESPACE": {"path": "/some/namespace.yml"},
21
+ "DESIRED_REF": "new_sha",
22
+ "DESIRED_TARGET_HASHES": [
30
23
  ConfigHash(
31
24
  channel="channel-a",
32
25
  target_config_hash="current_hash",
33
26
  parent_saas="parent_saas",
34
27
  )
35
28
  ],
36
- CHANNELS: ["channel-a"],
29
+ "CHANNELS": {"channel-a": {}},
37
30
  })
38
31
  saas_content, expected = file_contents("single_namespace")
39
32
  renderer = Renderer()
@@ -49,16 +42,16 @@ def test_content_single_namespace_no_previous_hash(
49
42
  subscriber_builder: Callable[[Mapping], Subscriber],
50
43
  ):
51
44
  subscriber = subscriber_builder({
52
- NAMESPACE: {"path": "/some/namespace.yml"},
53
- REF: "new_sha",
54
- CONFIG_HASHES: [
45
+ "NAMESPACE": {"path": "/some/namespace.yml"},
46
+ "DESIRED_REF": "new_sha",
47
+ "DESIRED_TARGET_HASHES": [
55
48
  ConfigHash(
56
49
  channel="channel-a",
57
50
  target_config_hash="new_hash",
58
51
  parent_saas="parent_saas",
59
52
  )
60
53
  ],
61
- CHANNELS: ["channel-a"],
54
+ "CHANNELS": {"channel-a": {}},
62
55
  })
63
56
  saas_content, expected = file_contents("single_namespace_no_hash")
64
57
  renderer = Renderer()
@@ -74,10 +67,10 @@ def test_content_single_namespace_no_desired_hash(
74
67
  subscriber_builder: Callable[[Mapping], Subscriber],
75
68
  ):
76
69
  subscriber = subscriber_builder({
77
- NAMESPACE: {"path": "/some/namespace.yml"},
78
- REF: "new_sha",
79
- CONFIG_HASHES: [],
80
- CHANNELS: ["channel-a"],
70
+ "NAMESPACE": {"path": "/some/namespace.yml"},
71
+ "DESIRED_REF": "new_sha",
72
+ "DESIRED_TARGET_HASHES": [],
73
+ "CHANNELS": {"channel-a": {}},
81
74
  })
82
75
  saas_content, expected = file_contents("single_namespace_ignore_hash")
83
76
  renderer = Renderer()
@@ -11,21 +11,15 @@ from reconcile.saas_auto_promotions_manager.subscriber import (
11
11
  Subscriber,
12
12
  )
13
13
 
14
- from .data_keys import (
15
- CONFIG_HASHES,
16
- NAMESPACE,
17
- REF,
18
- )
19
-
20
14
 
21
15
  def test_content_single_target(
22
16
  file_contents: Callable[[str], tuple[str, str]],
23
17
  subscriber_builder: Callable[[Mapping], Subscriber],
24
18
  ):
25
19
  subscriber = subscriber_builder({
26
- NAMESPACE: {"path": "/some/namespace.yml"},
27
- REF: "new_sha",
28
- CONFIG_HASHES: [
20
+ "NAMESPACE": {"path": "/some/namespace.yml"},
21
+ "DESIRED_REF": "new_sha",
22
+ "DESIRED_TARGET_HASHES": [
29
23
  ConfigHash(
30
24
  channel="channel-a",
31
25
  target_config_hash="new_hash",
@@ -48,9 +42,9 @@ def test_must_not_line_wrap(
48
42
  ):
49
43
  namespace_name = "/services/sosososolong/namespaces/loooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.yml"
50
44
  subscriber = subscriber_builder({
51
- NAMESPACE: {"path": namespace_name},
52
- REF: "new_sha",
53
- CONFIG_HASHES: [
45
+ "NAMESPACE": {"path": namespace_name},
46
+ "DESIRED_REF": "new_sha",
47
+ "DESIRED_TARGET_HASHES": [
54
48
  ConfigHash(
55
49
  channel="channel-a",
56
50
  target_config_hash="new_hash",
@@ -11,35 +11,28 @@ from reconcile.saas_auto_promotions_manager.subscriber import (
11
11
  Subscriber,
12
12
  )
13
13
 
14
- from .data_keys import (
15
- CHANNELS,
16
- CONFIG_HASHES,
17
- NAMESPACE,
18
- REF,
19
- )
20
-
21
14
 
22
15
  def test_json_path_selector_include(
23
16
  file_contents: Callable[[str], tuple[str, str]],
24
17
  subscriber_builder: Callable[[Mapping], Subscriber],
25
18
  ):
26
19
  subscriber = subscriber_builder({
27
- NAMESPACE: {
20
+ "NAMESPACE": {
28
21
  "path": "/some/namespace.yml",
29
22
  "name": "test-namespace",
30
23
  "cluster": {
31
24
  "name": "test-cluster",
32
25
  },
33
26
  },
34
- REF: "new_sha",
35
- CONFIG_HASHES: [
27
+ "DESIRED_REF": "new_sha",
28
+ "DESIRED_TARGET_HASHES": [
36
29
  ConfigHash(
37
30
  channel="channel-a",
38
31
  target_config_hash="new_hash",
39
32
  parent_saas="parent_saas",
40
33
  )
41
34
  ],
42
- CHANNELS: ["channel-a"],
35
+ "CHANNELS": {"channel-a": {}},
43
36
  })
44
37
  saas_content, expected = file_contents("json_path_selector_includes")
45
38
  renderer = Renderer()
@@ -55,22 +48,22 @@ def test_json_path_selector_exclude(
55
48
  subscriber_builder: Callable[[Mapping], Subscriber],
56
49
  ):
57
50
  subscriber = subscriber_builder({
58
- NAMESPACE: {
51
+ "NAMESPACE": {
59
52
  "path": "/some/namespace.yml",
60
53
  "name": "test-namespace",
61
54
  "cluster": {
62
55
  "name": "test-cluster",
63
56
  },
64
57
  },
65
- REF: "hyper_sha",
66
- CONFIG_HASHES: [
58
+ "DESIRED_REF": "hyper_sha",
59
+ "DESIRED_TARGET_HASHES": [
67
60
  ConfigHash(
68
61
  channel="channel-a",
69
62
  target_config_hash="hyper_hash",
70
63
  parent_saas="parent_saas",
71
64
  )
72
65
  ],
73
- CHANNELS: ["channel-a"],
66
+ "CHANNELS": {"channel-a": {}},
74
67
  })
75
68
  saas_content, expected = file_contents("json_path_selector_excludes")
76
69
  renderer = Renderer()
@@ -1,4 +0,0 @@
1
- REF = "ref"
2
- CONFIG_HASHES = "config_hashes"
3
- CHANNELS = "channels"
4
- NAMESPACE = "namespace"
@@ -1,89 +0,0 @@
1
- from collections import defaultdict
2
- from collections.abc import (
3
- Callable,
4
- Mapping,
5
- )
6
- from typing import Any
7
-
8
- import pytest
9
-
10
- from reconcile.gql_definitions.fragments.saas_target_namespace import (
11
- SaasTargetNamespace,
12
- )
13
- from reconcile.saas_auto_promotions_manager.publisher import (
14
- DeploymentInfo,
15
- Publisher,
16
- )
17
- from reconcile.saas_auto_promotions_manager.subscriber import (
18
- Channel,
19
- ConfigHash,
20
- Subscriber,
21
- )
22
-
23
- from .data_keys import (
24
- CHANNELS,
25
- CONFIG_HASH,
26
- CUR_CONFIG_HASHES,
27
- CUR_SUBSCRIBER_REF,
28
- DESIRED_REF,
29
- DESIRED_TARGET_HASHES,
30
- NAMESPACE,
31
- REAL_WORLD_SHA,
32
- SUCCESSFUL_DEPLOYMENT,
33
- TARGET_FILE_PATH,
34
- USE_TARGET_CONFIG_HASH,
35
- )
36
-
37
-
38
- @pytest.fixture
39
- def subscriber_builder(
40
- saas_target_namespace_builder: Callable[..., SaasTargetNamespace],
41
- ) -> Callable[[Mapping[str, Any]], Subscriber]:
42
- def builder(data: Mapping[str, Any]) -> Subscriber:
43
- channels: list[Channel] = []
44
- for channel_name, channel_data in data.get(CHANNELS, {}).items():
45
- channel = Channel(name=channel_name, publishers=[])
46
- for publisher_name, publisher_data in channel_data.items():
47
- publisher = Publisher(
48
- ref="",
49
- uid="",
50
- repo_url="",
51
- cluster_name="",
52
- namespace_name="",
53
- saas_name="",
54
- saas_file_path="",
55
- app_name="",
56
- resource_template_name="",
57
- target_name=None,
58
- publish_job_logs=True,
59
- has_subscriber=True,
60
- auth_code=None,
61
- )
62
- publisher.commit_sha = publisher_data[REAL_WORLD_SHA]
63
- publisher.deployment_info_by_channel[channel_name] = DeploymentInfo(
64
- success=publisher_data.get(SUCCESSFUL_DEPLOYMENT, True),
65
- target_config_hash=publisher_data.get(CONFIG_HASH, ""),
66
- saas_file=publisher_name,
67
- )
68
- channel.publishers.append(publisher)
69
- channels.append(channel)
70
- cur_config_hashes_by_channel: dict[str, list[ConfigHash]] = defaultdict(list)
71
- for cur_config_hash in data.get(CUR_CONFIG_HASHES, []):
72
- cur_config_hashes_by_channel[cur_config_hash.channel].append(
73
- cur_config_hash
74
- )
75
- subscriber = Subscriber(
76
- target_namespace=saas_target_namespace_builder(data.get(NAMESPACE, {})),
77
- ref=data.get(CUR_SUBSCRIBER_REF, ""),
78
- saas_name="",
79
- target_file_path=data.get(TARGET_FILE_PATH, ""),
80
- template_name="",
81
- use_target_config_hash=data.get(USE_TARGET_CONFIG_HASH, True),
82
- )
83
- subscriber.channels = channels
84
- subscriber.config_hashes_by_channel_name = cur_config_hashes_by_channel
85
- subscriber.desired_ref = data.get(DESIRED_REF, "")
86
- subscriber.desired_hashes = data.get(DESIRED_TARGET_HASHES, [])
87
- return subscriber
88
-
89
- return builder
@@ -1,11 +0,0 @@
1
- CUR_SUBSCRIBER_REF = "cur_subscriber_ref"
2
- REAL_WORLD_SHA = "real_world_sha"
3
- CONFIG_HASH = "config_hash"
4
- CHANNELS = "channels"
5
- SUCCESSFUL_DEPLOYMENT = "successful_deployment"
6
- CUR_CONFIG_HASHES = "cur_config_hashes"
7
- TARGET_FILE_PATH = "target_file_path"
8
- DESIRED_REF = "desired_ref"
9
- DESIRED_TARGET_HASHES = "desired_target_hashes"
10
- USE_TARGET_CONFIG_HASH = "use_target_config_hash"
11
- NAMESPACE = "namespace"
@@ -1,130 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Mapping,
4
- )
5
-
6
- from reconcile.saas_auto_promotions_manager.subscriber import (
7
- CONTENT_HASH_LENGTH,
8
- ConfigHash,
9
- Subscriber,
10
- )
11
-
12
- from .data_keys import (
13
- DESIRED_REF,
14
- DESIRED_TARGET_HASHES,
15
- NAMESPACE,
16
- TARGET_FILE_PATH,
17
- )
18
-
19
-
20
- def test_can_compute_content_hash(subscriber_builder: Callable[[Mapping], Subscriber]):
21
- subscribers = [
22
- subscriber_builder({
23
- NAMESPACE: {"path": "some_namespace"},
24
- TARGET_FILE_PATH: "some_saas",
25
- DESIRED_REF: "new",
26
- DESIRED_TARGET_HASHES: [
27
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
28
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
29
- ],
30
- }),
31
- subscriber_builder({
32
- NAMESPACE: {"path": "other_namespace"},
33
- TARGET_FILE_PATH: "other_saas",
34
- DESIRED_REF: "new",
35
- DESIRED_TARGET_HASHES: [
36
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
37
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
38
- ],
39
- }),
40
- ]
41
- assert (
42
- len(Subscriber.combined_content_hash(subscribers=subscribers))
43
- == CONTENT_HASH_LENGTH
44
- )
45
-
46
-
47
- def test_content_hash_is_deterministic(
48
- subscriber_builder: Callable[[Mapping], Subscriber],
49
- ):
50
- subscribers = [
51
- subscriber_builder({
52
- NAMESPACE: {"path": "some_namespace"},
53
- TARGET_FILE_PATH: "some_saas",
54
- DESIRED_REF: "new",
55
- DESIRED_TARGET_HASHES: [
56
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
57
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
58
- ],
59
- }),
60
- subscriber_builder({
61
- NAMESPACE: {"path": "other_namespace"},
62
- TARGET_FILE_PATH: "other_saas",
63
- DESIRED_REF: "old",
64
- DESIRED_TARGET_HASHES: [
65
- ConfigHash(channel="h", target_config_hash="i", parent_saas="j"),
66
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
67
- ],
68
- }),
69
- ]
70
- hashes = set()
71
- for _ in range(3):
72
- hashes.add(Subscriber.combined_content_hash(subscribers=subscribers))
73
- assert len(hashes) == 1
74
-
75
-
76
- def test_content_hash_differs(subscriber_builder: Callable[[Mapping], Subscriber]):
77
- subscriber_a = subscriber_builder({
78
- NAMESPACE: {"path": "some_namespace"},
79
- TARGET_FILE_PATH: "some_saas",
80
- DESIRED_REF: "new",
81
- DESIRED_TARGET_HASHES: [
82
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
83
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
84
- ],
85
- })
86
-
87
- subscriber_b = subscriber_builder({
88
- NAMESPACE: {"path": "some_namespace"},
89
- TARGET_FILE_PATH: "some_other_saas",
90
- DESIRED_REF: "new",
91
- DESIRED_TARGET_HASHES: [
92
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
93
- ],
94
- })
95
-
96
- assert Subscriber.combined_content_hash([
97
- subscriber_a
98
- ]) != Subscriber.combined_content_hash([subscriber_b])
99
-
100
-
101
- def test_content_hash_equals(subscriber_builder: Callable[[Mapping], Subscriber]):
102
- subscriber_a = subscriber_builder({
103
- NAMESPACE: {"path": "some_namespace"},
104
- TARGET_FILE_PATH: "some_saas",
105
- DESIRED_REF: "new",
106
- DESIRED_TARGET_HASHES: [
107
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
108
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
109
- ConfigHash(channel="h", target_config_hash="i", parent_saas="j"),
110
- ConfigHash(channel="k", target_config_hash="l", parent_saas="m"),
111
- ],
112
- })
113
- subscriber_b = subscriber_builder({
114
- NAMESPACE: {"path": "some_namespace"},
115
- TARGET_FILE_PATH: "some_saas",
116
- DESIRED_REF: "new",
117
- DESIRED_TARGET_HASHES: list(
118
- reversed([
119
- ConfigHash(channel="a", target_config_hash="b", parent_saas="c"),
120
- ConfigHash(channel="e", target_config_hash="f", parent_saas="g"),
121
- ConfigHash(channel="h", target_config_hash="i", parent_saas="j"),
122
- ConfigHash(channel="k", target_config_hash="l", parent_saas="m"),
123
- ])
124
- ),
125
- })
126
-
127
- assert Subscriber.combined_content_hash([
128
- subscriber_a,
129
- subscriber_b,
130
- ]) == Subscriber.combined_content_hash([subscriber_b, subscriber_a])
@@ -1,161 +0,0 @@
1
- from collections.abc import (
2
- Callable,
3
- Mapping,
4
- )
5
- from typing import Any
6
-
7
- from reconcile.saas_auto_promotions_manager.subscriber import (
8
- ConfigHash,
9
- Subscriber,
10
- )
11
-
12
- from .data_keys import (
13
- CUR_CONFIG_HASHES,
14
- CUR_SUBSCRIBER_REF,
15
- DESIRED_REF,
16
- DESIRED_TARGET_HASHES,
17
- )
18
-
19
-
20
- def test_has_config_hash_diff(
21
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
22
- ) -> None:
23
- subscriber = subscriber_builder({
24
- CUR_SUBSCRIBER_REF: "current_sha",
25
- CUR_CONFIG_HASHES: [
26
- ConfigHash(
27
- channel="channel-a",
28
- parent_saas="publisher_a",
29
- target_config_hash="pub_a_hash",
30
- ),
31
- ConfigHash(
32
- channel="channel-b",
33
- parent_saas="publisher_b",
34
- target_config_hash="pub_b_hash",
35
- ),
36
- ],
37
- DESIRED_REF: "current_sha",
38
- DESIRED_TARGET_HASHES: [
39
- ConfigHash(
40
- channel="channel-a",
41
- parent_saas="publisher_a",
42
- target_config_hash="pub_a_hash",
43
- ),
44
- ConfigHash(
45
- channel="channel-b",
46
- parent_saas="publisher_b",
47
- target_config_hash="new_hash",
48
- ),
49
- ],
50
- })
51
- assert subscriber.has_diff()
52
-
53
-
54
- def test_has_ref_diff(
55
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
56
- ) -> None:
57
- subscriber = subscriber_builder({
58
- CUR_SUBSCRIBER_REF: "current_sha",
59
- CUR_CONFIG_HASHES: [],
60
- DESIRED_REF: "new_sha",
61
- DESIRED_TARGET_HASHES: [],
62
- })
63
- assert subscriber.has_diff()
64
-
65
-
66
- def test_no_diff(
67
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
68
- ) -> None:
69
- config_hashes = [
70
- ConfigHash(
71
- channel="channel-a",
72
- parent_saas="publisher_a",
73
- target_config_hash="pub_a_hash",
74
- ),
75
- ConfigHash(
76
- channel="channel-b",
77
- parent_saas="publisher_b",
78
- target_config_hash="pub_b_hash",
79
- ),
80
- ]
81
- subscriber = subscriber_builder({
82
- CUR_SUBSCRIBER_REF: "current_sha",
83
- CUR_CONFIG_HASHES: config_hashes,
84
- DESIRED_REF: "current_sha",
85
- DESIRED_TARGET_HASHES: list(reversed(config_hashes)),
86
- })
87
- assert not subscriber.has_diff()
88
-
89
-
90
- def test_hashes_desired_subset_of_current(
91
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
92
- ) -> None:
93
- """
94
- We do not react on additional current hashes, i.e., SAPM is not responsible
95
- for deleting dangling hashes -> we only care about desired hashes being in place.
96
- """
97
- subscriber = subscriber_builder({
98
- CUR_SUBSCRIBER_REF: "current_sha",
99
- CUR_CONFIG_HASHES: [
100
- ConfigHash(
101
- channel="channel-a",
102
- parent_saas="saas-a",
103
- target_config_hash="hash-a",
104
- ),
105
- ConfigHash(
106
- channel="channel-b",
107
- parent_saas="saas-b",
108
- target_config_hash="hash-b",
109
- ),
110
- ],
111
- DESIRED_REF: "current_sha",
112
- DESIRED_TARGET_HASHES: [
113
- ConfigHash(
114
- channel="channel-b",
115
- parent_saas="saas-b",
116
- target_config_hash="hash-b",
117
- ),
118
- ],
119
- })
120
- assert not subscriber.has_diff()
121
-
122
-
123
- def test_hashes_current_subset_of_desired(
124
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
125
- ) -> None:
126
- subscriber = subscriber_builder({
127
- CUR_SUBSCRIBER_REF: "current_sha",
128
- CUR_CONFIG_HASHES: [
129
- ConfigHash(
130
- channel="channel-b",
131
- parent_saas="saas-b",
132
- target_config_hash="hash-b",
133
- ),
134
- ],
135
- DESIRED_REF: "current_sha",
136
- DESIRED_TARGET_HASHES: [
137
- ConfigHash(
138
- channel="channel-a",
139
- parent_saas="saas-a",
140
- target_config_hash="hash-a",
141
- ),
142
- ConfigHash(
143
- channel="channel-b",
144
- parent_saas="saas-b",
145
- target_config_hash="hash-b",
146
- ),
147
- ],
148
- })
149
- assert subscriber.has_diff()
150
-
151
-
152
- def test_empty_hashes(
153
- subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
154
- ) -> None:
155
- subscriber = subscriber_builder({
156
- CUR_SUBSCRIBER_REF: "current_sha",
157
- CUR_CONFIG_HASHES: [],
158
- DESIRED_REF: "current_sha",
159
- DESIRED_TARGET_HASHES: [],
160
- })
161
- assert not subscriber.has_diff()