Skip to content

Commit

Permalink
Simplify the test comment
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Nov 12, 2024
1 parent 7ca2b37 commit a267934
Showing 1 changed file with 17 additions and 53 deletions.
70 changes: 17 additions & 53 deletions src/olympia/blocklist/tests/test_mlbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,81 +464,35 @@ def test_diff_all_possible_changes(self):
5. Blocked -> Soft blocked
6. Blocked -> Not blocked
first stash
{
'blocked': [5,6],
'softblocked': [3,4],
# 1,2 are already unblocked so wouldn't be on the stash
'unblocked': [],
}
In old clients:
1: not blocked
2: not blocked
3: not blocked
4: not blocked
5: blocked
6: blocked
In new clients:
1: not blocked
2: not blocked
3: soft blocked
4: soft blocked
5: blocked
6: blocked
second stash
{
'blocked': [2,3],
'softblocked': [1,5],
'unblocked': [4,5,6],
}
In old clients:
1: not blocked
2: blocked
3: blocked
4: not blocked
5: not blocked
6: not blocked
In new clients:
1: soft blocked
2: blocked
3: blocked
4: not blocked
5: soft blocked
6: not blocked
"""
# 1. Not blocked -> Soft blocked
# 1. (Not blocked) -> Soft blocked
one = addon_factory(guid='1', file_kw={'is_signed': True})
(one_hash,) = MLBF.hash_filter_inputs([(one.guid, one.current_version.version)])
# 2. Not blocked -> Blocked
# 2. (Not blocked) -> Blocked
two = addon_factory(guid='2', file_kw={'is_signed': True})
(two_hash,) = MLBF.hash_filter_inputs([(two.guid, two.current_version.version)])
# 3. Soft blocked -> Blocked
# 3. (Soft blocked) -> (Blocked)
three, three_block = self._blocked_addon(
guid='3', block_type=BlockType.SOFT_BLOCKED, file_kw={'is_signed': True}
)
(three_hash,) = MLBF.hash_filter_inputs(
[(three.guid, three.current_version.version)]
)
# 4. Soft blocked -> Not blocked
# 4. (Soft blocked) -> (Not blocked)
four, four_block = self._blocked_addon(
guid='4', block_type=BlockType.SOFT_BLOCKED, file_kw={'is_signed': True}
)
(four_hash,) = MLBF.hash_filter_inputs(
[(four.guid, four.current_version.version)]
)
# 5. Blocked -> Soft blocked
# 5. (Blocked) -> (Soft blocked)
five, five_block = self._blocked_addon(
guid='5', block_type=BlockType.BLOCKED, file_kw={'is_signed': True}
)
(five_hash,) = MLBF.hash_filter_inputs(
[(five.guid, five.current_version.version)]
)
# 6. Blocked -> Not blocked
# 6. (Blocked) -> (Not blocked)
six, six_block = self._blocked_addon(
guid='6', block_type=BlockType.BLOCKED, file_kw={'is_signed': True}
)
Expand All @@ -550,20 +504,30 @@ def test_diff_all_possible_changes(self):
BlockType.BLOCKED: ([five_hash, six_hash], [], 2),
BlockType.SOFT_BLOCKED: ([three_hash, four_hash], [], 2),
}

# The first time we generate the stash, we expect 3-6 to be in the stash
# as they have some kind of block applied
assert first_mlbf.generate_and_write_stash() == {
'blocked': [five_hash, six_hash],
'softblocked': [three_hash, four_hash],
'unblocked': [],
}

# Transform the addons
# Transform the addons to the next state

# 1. Not blocked -> (Soft blocked)
block_factory(
guid=one.guid, updated_by=self.user, block_type=BlockType.SOFT_BLOCKED
)
# 2. Not blocked -> (Blocked)
block_factory(guid=two.guid, updated_by=self.user, block_type=BlockType.BLOCKED)
# 3. Soft blocked -> (Blocked)
three_block.blockversion_set.first().update(block_type=BlockType.BLOCKED)
# 4. Soft blocked -> (Not blocked)
four_block.delete()
# 5. Blocked -> (Soft blocked)
five_block.blockversion_set.first().update(block_type=BlockType.SOFT_BLOCKED)
# 6. Blocked -> (Not blocked)
six_block.delete()

second_mlbf = MLBF.generate_from_db('second')
Expand Down

0 comments on commit a267934

Please sign in to comment.