test_unmerge.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. from sentry.unmerge import (
  2. InitialUnmergeArgs,
  3. PrimaryHashUnmergeReplacement,
  4. SuccessiveUnmergeArgs,
  5. UnmergeArgsBase,
  6. )
  7. def test_argument_parsing_endpoint():
  8. """
  9. Tests task invocations done from group_hashes endpoint.
  10. """
  11. args = UnmergeArgsBase.parse_arguments(123, 345, None, ["a" * 32], None)
  12. assert args == InitialUnmergeArgs(
  13. project_id=123,
  14. source_id=345,
  15. destinations={},
  16. replacement=PrimaryHashUnmergeReplacement(
  17. fingerprints=["a" * 32],
  18. ),
  19. actor_id=None,
  20. batch_size=500,
  21. )
  22. dumped = args.dump_arguments()
  23. assert dumped == {
  24. "actor_id": None,
  25. "batch_size": 500,
  26. "destination_id": None,
  27. "destinations": {},
  28. "fingerprints": None,
  29. "project_id": 123,
  30. "replacement": {
  31. "fingerprints": [
  32. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  33. ],
  34. "type": "primary_hash",
  35. },
  36. "source_id": 345,
  37. }
  38. assert UnmergeArgsBase.parse_arguments(**dumped) == args
  39. def test_argument_parsing_page2():
  40. """
  41. Tests task invocations done from an older version of the unmerge task.
  42. This test only exists such that argument parsing is not broken across
  43. deploys, but in a few years it may be fine to break compat with old queue
  44. items and remove this test.
  45. """
  46. args = UnmergeArgsBase.parse_arguments(
  47. 123,
  48. 345,
  49. 567,
  50. ["a" * 32],
  51. 666,
  52. last_event={"hello": "world"},
  53. batch_size=500,
  54. source_fields_reset=True,
  55. eventstream_state={"state": True},
  56. )
  57. assert args == SuccessiveUnmergeArgs(
  58. project_id=123,
  59. source_id=345,
  60. destinations={"default": (567, {"state": True})},
  61. replacement=PrimaryHashUnmergeReplacement(fingerprints=["a" * 32]),
  62. actor_id=666,
  63. last_event={"hello": "world"},
  64. locked_primary_hashes=["a" * 32],
  65. batch_size=500,
  66. source_fields_reset=True,
  67. )
  68. assert UnmergeArgsBase.parse_arguments(**args.dump_arguments()) == args