qontract-reconcile 0.9.1rc273__py3-none-any.whl → 0.9.1rc275__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.
@@ -1,6 +1,5 @@
1
1
  from collections.abc import (
2
2
  Callable,
3
- Iterable,
4
3
  Mapping,
5
4
  )
6
5
  from typing import Any
@@ -22,15 +21,16 @@ from .data_keys import (
22
21
 
23
22
  def test_no_change(
24
23
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
25
- config_hashes_builder: Callable[
26
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
27
- ],
28
24
  ):
29
25
  subscriber = subscriber_builder(
30
26
  {
31
27
  CUR_SUBSCRIBER_REF: "current_sha",
32
28
  CUR_CONFIG_HASHES: [
33
- ("channel-a", "publisher_a", "current_hash"),
29
+ ConfigHash(
30
+ channel="channel-a",
31
+ parent_saas="publisher_a",
32
+ target_config_hash="current_hash",
33
+ ),
34
34
  ],
35
35
  CHANNELS: {
36
36
  "channel-a": {
@@ -43,24 +43,29 @@ def test_no_change(
43
43
  }
44
44
  )
45
45
  subscriber.compute_desired_state()
46
- expected_config_hashes = config_hashes_builder(
47
- [("channel-a", "publisher_a", "current_hash")]
48
- )
46
+ expected_config_hashes = [
47
+ ConfigHash(
48
+ channel="channel-a",
49
+ parent_saas="publisher_a",
50
+ target_config_hash="current_hash",
51
+ )
52
+ ]
49
53
  assert subscriber.desired_ref == "current_sha"
50
54
  assert subscriber.desired_hashes == expected_config_hashes
51
55
 
52
56
 
53
57
  def test_moving_ref(
54
58
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
55
- config_hashes_builder: Callable[
56
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
57
- ],
58
59
  ):
59
60
  subscriber = subscriber_builder(
60
61
  {
61
62
  CUR_SUBSCRIBER_REF: "current_sha",
62
63
  CUR_CONFIG_HASHES: [
63
- ("channel-a", "publisher_a", "current_hash"),
64
+ ConfigHash(
65
+ channel="channel-a",
66
+ parent_saas="publisher_a",
67
+ target_config_hash="current_hash",
68
+ ),
64
69
  ],
65
70
  CHANNELS: {
66
71
  "channel-a": {
@@ -73,24 +78,29 @@ def test_moving_ref(
73
78
  }
74
79
  )
75
80
  subscriber.compute_desired_state()
76
- expected_config_hashes = config_hashes_builder(
77
- [("channel-a", "publisher_a", "current_hash")]
78
- )
81
+ expected_config_hashes = [
82
+ ConfigHash(
83
+ channel="channel-a",
84
+ parent_saas="publisher_a",
85
+ target_config_hash="current_hash",
86
+ )
87
+ ]
79
88
  assert subscriber.desired_ref == "new_sha"
80
89
  assert subscriber.desired_hashes == expected_config_hashes
81
90
 
82
91
 
83
92
  def test_moving_ref_bad_deployment(
84
93
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
85
- config_hashes_builder: Callable[
86
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
87
- ],
88
94
  ):
89
95
  subscriber = subscriber_builder(
90
96
  {
91
97
  CUR_SUBSCRIBER_REF: "current_sha",
92
98
  CUR_CONFIG_HASHES: [
93
- ("channel-a", "publisher_a", "current_hash"),
99
+ ConfigHash(
100
+ channel="channel-a",
101
+ parent_saas="publisher_a",
102
+ target_config_hash="current_hash",
103
+ ),
94
104
  ],
95
105
  CHANNELS: {
96
106
  "channel-a": {
@@ -104,24 +114,29 @@ def test_moving_ref_bad_deployment(
104
114
  }
105
115
  )
106
116
  subscriber.compute_desired_state()
107
- expected_config_hashes = config_hashes_builder(
108
- [("channel-a", "publisher_a", "current_hash")]
109
- )
117
+ expected_config_hashes = [
118
+ ConfigHash(
119
+ channel="channel-a",
120
+ parent_saas="publisher_a",
121
+ target_config_hash="current_hash",
122
+ )
123
+ ]
110
124
  assert subscriber.desired_ref == "current_sha"
111
125
  assert subscriber.desired_hashes == expected_config_hashes
112
126
 
113
127
 
114
128
  def test_new_config_hash(
115
129
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
116
- config_hashes_builder: Callable[
117
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
118
- ],
119
130
  ):
120
131
  subscriber = subscriber_builder(
121
132
  {
122
133
  CUR_SUBSCRIBER_REF: "current_sha",
123
134
  CUR_CONFIG_HASHES: [
124
- ("channel-a", "publisher_a", "current_hash"),
135
+ ConfigHash(
136
+ channel="channel-a",
137
+ parent_saas="publisher_a",
138
+ target_config_hash="current_hash",
139
+ ),
125
140
  ],
126
141
  CHANNELS: {
127
142
  "channel-a": {
@@ -134,24 +149,29 @@ def test_new_config_hash(
134
149
  }
135
150
  )
136
151
  subscriber.compute_desired_state()
137
- expected_config_hashes = config_hashes_builder(
138
- [("channel-a", "publisher_a", "new_hash")]
139
- )
152
+ expected_config_hashes = [
153
+ ConfigHash(
154
+ channel="channel-a",
155
+ parent_saas="publisher_a",
156
+ target_config_hash="new_hash",
157
+ )
158
+ ]
140
159
  assert subscriber.desired_ref == "current_sha"
141
160
  assert subscriber.desired_hashes == expected_config_hashes
142
161
 
143
162
 
144
163
  def test_new_config_hash_bad_deployment(
145
164
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
146
- config_hashes_builder: Callable[
147
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
148
- ],
149
165
  ):
150
166
  subscriber = subscriber_builder(
151
167
  {
152
168
  CUR_SUBSCRIBER_REF: "current_sha",
153
169
  CUR_CONFIG_HASHES: [
154
- ("channel-a", "publisher_a", "current_hash"),
170
+ ConfigHash(
171
+ channel="channel-a",
172
+ parent_saas="publisher_a",
173
+ target_config_hash="current_hash",
174
+ ),
155
175
  ],
156
176
  CHANNELS: {
157
177
  "channel-a": {
@@ -165,24 +185,29 @@ def test_new_config_hash_bad_deployment(
165
185
  }
166
186
  )
167
187
  subscriber.compute_desired_state()
168
- expected_config_hashes = config_hashes_builder(
169
- [("channel-a", "publisher_a", "current_hash")]
170
- )
188
+ expected_config_hashes = [
189
+ ConfigHash(
190
+ channel="channel-a",
191
+ parent_saas="publisher_a",
192
+ target_config_hash="current_hash",
193
+ )
194
+ ]
171
195
  assert subscriber.desired_ref == "current_sha"
172
196
  assert subscriber.desired_hashes == expected_config_hashes
173
197
 
174
198
 
175
199
  def test_new_config_hash_and_moving_ref(
176
200
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
177
- config_hashes_builder: Callable[
178
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
179
- ],
180
201
  ):
181
202
  subscriber = subscriber_builder(
182
203
  {
183
204
  CUR_SUBSCRIBER_REF: "current_sha",
184
205
  CUR_CONFIG_HASHES: [
185
- ("channel-a", "publisher_a", "current_hash"),
206
+ ConfigHash(
207
+ channel="channel-a",
208
+ parent_saas="publisher_a",
209
+ target_config_hash="current_hash",
210
+ ),
186
211
  ],
187
212
  CHANNELS: {
188
213
  "channel-a": {
@@ -195,24 +220,29 @@ def test_new_config_hash_and_moving_ref(
195
220
  }
196
221
  )
197
222
  subscriber.compute_desired_state()
198
- expected_config_hashes = config_hashes_builder(
199
- [("channel-a", "publisher_a", "new_hash")]
200
- )
223
+ expected_config_hashes = [
224
+ ConfigHash(
225
+ channel="channel-a",
226
+ parent_saas="publisher_a",
227
+ target_config_hash="new_hash",
228
+ )
229
+ ]
201
230
  assert subscriber.desired_ref == "new_sha"
202
231
  assert subscriber.desired_hashes == expected_config_hashes
203
232
 
204
233
 
205
234
  def test_new_config_hash_and_moving_ref_and_bad_deployment(
206
235
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
207
- config_hashes_builder: Callable[
208
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
209
- ],
210
236
  ):
211
237
  subscriber = subscriber_builder(
212
238
  {
213
239
  CUR_SUBSCRIBER_REF: "current_sha",
214
240
  CUR_CONFIG_HASHES: [
215
- ("channel-a", "publisher_a", "current_hash"),
241
+ ConfigHash(
242
+ channel="channel-a",
243
+ parent_saas="publisher_a",
244
+ target_config_hash="current_hash",
245
+ ),
216
246
  ],
217
247
  CHANNELS: {
218
248
  "channel-a": {
@@ -226,18 +256,19 @@ def test_new_config_hash_and_moving_ref_and_bad_deployment(
226
256
  }
227
257
  )
228
258
  subscriber.compute_desired_state()
229
- expected_config_hashes = config_hashes_builder(
230
- [("channel-a", "publisher_a", "current_hash")]
231
- )
259
+ expected_config_hashes = [
260
+ ConfigHash(
261
+ channel="channel-a",
262
+ parent_saas="publisher_a",
263
+ target_config_hash="current_hash",
264
+ )
265
+ ]
232
266
  assert subscriber.desired_ref == "current_sha"
233
267
  assert subscriber.desired_hashes == expected_config_hashes
234
268
 
235
269
 
236
270
  def test_cur_config_hash_did_not_exist(
237
271
  subscriber_builder: Callable[[Mapping[str, Any]], Subscriber],
238
- config_hashes_builder: Callable[
239
- [Iterable[tuple[str, str, str]]], frozenset[ConfigHash]
240
- ],
241
272
  ):
242
273
  subscriber = subscriber_builder(
243
274
  {
@@ -254,8 +285,12 @@ def test_cur_config_hash_did_not_exist(
254
285
  }
255
286
  )
256
287
  subscriber.compute_desired_state()
257
- expected_config_hashes = config_hashes_builder(
258
- [("channel-a", "publisher_a", "new_hash")]
259
- )
288
+ expected_config_hashes = [
289
+ ConfigHash(
290
+ channel="channel-a",
291
+ parent_saas="publisher_a",
292
+ target_config_hash="new_hash",
293
+ )
294
+ ]
260
295
  assert subscriber.desired_ref == "current_sha"
261
296
  assert subscriber.desired_hashes == expected_config_hashes