Skip to content

Commit

Permalink
test: ensure that xapi event UUIDs remain unchanged.
Browse files Browse the repository at this point in the history
* stops mocking uuid5 during tests
  uuid5 generates the same UUID when provided with the same namespace + name,
  and so we can rely on this remaining the same in the expected fixture files.
* updates test data to use the actual uuid5s generated for the given input events.
  • Loading branch information
pomegranited committed Aug 9, 2023
1 parent ea3d27d commit 885f476
Show file tree
Hide file tree
Showing 60 changed files with 82 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from abc import abstractmethod
from unittest.mock import patch
from uuid import UUID

import ddt
from django.contrib.auth import get_user_model
Expand Down Expand Up @@ -89,11 +90,12 @@ def compare_events(self, transformed_event, expected_event):
Every transformer's test case will implement its own logic to test
events transformation
"""
@patch('event_routing_backends.helpers.uuid')
@patch('event_routing_backends.helpers.uuid.uuid4')
@ddt.data(*EVENT_FIXTURE_FILENAMES)
def test_event_transformer(self, event_filename, mocked_uuid):
mocked_uuid.uuid4.return_value = '32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb'
mocked_uuid.uuid5.return_value = '32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb'
def test_event_transformer(self, event_filename, mocked_uuid4):
# Used to generate the anonymized actor.name,
# which in turn is used to generate the event UUID.
mocked_uuid4.return_value = UUID('32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb')

# if an event's expected fixture doesn't exist, the test shouldn't fail.
# evaluate transformation of only supported event fixtures.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "f7c8b743-f18f-5016-8455-35ff8a2f8020",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "bb946682-b0b9-5dc2-a17c-605ef5833c98",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "bb946682-b0b9-5dc2-a17c-605ef5833c98",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "bb946682-b0b9-5dc2-a17c-605ef5833c98",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "074afb4a-90d6-57d6-8a6a-4867b4bfcc5f",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "bb946682-b0b9-5dc2-a17c-605ef5833c98",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "ecf2a41b-d1c8-50f7-bd6f-79b305159dae",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "ebfef69f-dd05-5bf0-bf90-bad645bc6992",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "ebfef69f-dd05-5bf0-bf90-bad645bc6992",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "b57c965a-218a-5a17-aee8-9f3dc75c5bb3",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "54acd352-b4f5-56fb-a328-d7fa43d90710",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "196cf44f-9d76-5d76-ac0d-683359d9b88b",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "b52e9a1c-3ff6-5841-8cb3-d9edbed4fc4f",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "23ae2117-975a-5669-9d1d-cc47928b1959",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "806c7c48-7df6-56b9-bdb0-c379a968acf5",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "a4e3d431-0281-5b3e-bcf7-0ddbeb8543b2",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "e57ea5a8-ad20-5717-b648-824bede138aa",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "ae1a9bfe-2d3b-5afd-87f4-ad8d4c596932",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "81c7f03f-e07e-5b54-9095-f5019e5bbef3",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "0ce637d7-e823-5447-8cdf-8da3afb4fd9b",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "d1325940-fe1b-5042-90c1-e3365960c9a1",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "883a9580-f6bc-55b6-b5c8-1d5a13a8bdd7",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "a10da8af-8e6a-5d1c-b7d5-cdabaacc0ba8",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "a10da8af-8e6a-5d1c-b7d5-cdabaacc0ba8",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "1940cdf9-6a89-5cb7-82f9-5b0955584db8",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "e9b9ba0f-d976-5656-9a6c-d432b12335ea",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "01b620b3-0cba-556e-96d5-d1e9ef63489d",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "01b620b3-0cba-556e-96d5-d1e9ef63489d",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "01b620b3-0cba-556e-96d5-d1e9ef63489d",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "d30c30af-2eeb-5ae3-a765-4e2ca9bb3283",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "2802561d-3e8e-56d4-8944-07a8fbfd02b2",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "6e0efdce-2611-52f8-a213-dcd81b78cfbd",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "0f73de3b-445e-5674-aab9-b0117c64671a",
"actor": {
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"},
"objectType": "Agent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "9e08cf47-e86f-5b64-b48f-a4d524f9a7e4",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "9e08cf47-e86f-5b64-b48f-a4d524f9a7e4",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "0b9e39477cf34507a7a48f74be381fdd",
"id": "8c936f51-267d-51ad-a850-9fffdb7595de",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "3feca024-a2a2-5ee3-9307-50711dc48abd",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "3feca024-a2a2-5ee3-9307-50711dc48abd",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "b2fff5f6-c77d-5aa4-a08b-bb547d6ee5a6",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "203e182c-6a2d-5458-9c61-a271297d459a",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "2a1f0f7c-6636-52df-913b-59e2f197a58e",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "37e0953c-fa85-5435-8c53-723909ab81d9",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "2a1f0f7c-6636-52df-913b-59e2f197a58e",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "c9c7da1a-0cf0-5161-9bf5-35c61091f826",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "c9c7da1a-0cf0-5161-9bf5-35c61091f826",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "6d1f033b-3f70-458c-b53a-e6bb63cbaef9",
"id": "c9c7da1a-0cf0-5161-9bf5-35c61091f826",
"actor": {
"objectType": "Agent",
"account": {"homePage": "http://localhost:18000", "name": "32e08e30-f8ae-4ce2-94a8-c2bfe38a70cb"}
Expand Down
Loading

0 comments on commit 885f476

Please sign in to comment.