Skip to content

Commit

Permalink
Add advanced mapper use case payload unit test payload/response valid…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
san99tiago committed Sep 2, 2023
1 parent e677720 commit 706ca80
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/unit/mapper/destination_response_good_01.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"id": "2008d4d2-49fd-48e4-a305-796b75953edd",
"author": "Japanese Proverb",
"quote": "Discipline will sooner or later defeat intelligence",
"quality": 5,
"quality": "AWESOME",
"category": "Discipline",
"sentiment": "Positive",
"allTypes": [
Expand All @@ -26,7 +26,7 @@
"id": "ab93c944-8c77-4e79-84e4-c78cb125f1ad",
"author": "Alex Hormozi",
"quote": "The longer you delay the ask, the bigger the ask you can make",
"quality": 5,
"quality": "AWESOME",
"category": "Success",
"sentiment": "Positive",
"allTypes": [
Expand All @@ -51,7 +51,7 @@
"id": "98d42874-29ad-47f8-977c-ba51857ae3ee",
"author": "Benjamin Franklin",
"quote": "Well done is better than well said",
"quality": 4,
"quality": "N/A",
"category": "Life",
"sentiment": "Positive",
"allTypes": [
Expand All @@ -70,7 +70,7 @@
"id": "419364b4-0e60-425a-8548-b14020b442ea",
"author": "Charles F. Kettering",
"quote": "A problem well stated is a problem half solved",
"quality": 3
"quality": "GOOD"
}
]
}
20 changes: 19 additions & 1 deletion tests/unit/mapper/test_mapper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import pytest
from src.mapper.mapper import Mapper
from jsonpath_ng.jsonpath import JSONPath


# Mocking os.path.join to avoid reading a real JSON mapper file
Expand Down Expand Up @@ -170,3 +171,20 @@ def test_mapper_convert_payload_multiple():
]
}
}


def test_mapper_real_complete_payload_01():
from src.mapper.mapper import Mapper

current_dir = os.path.dirname(os.path.abspath(__file__))
payload_path = os.path.join(current_dir, "source_payload_good_01.json")
response_path = os.path.join(current_dir, "destination_response_good_01.json")

with open(payload_path, "r") as payload_file:
payload = json.load(payload_file)

with open(response_path, "r") as response_file:
expected_response = json.load(response_file)

mapper = Mapper(payload)
assert mapper.convert_payload() == expected_response

0 comments on commit 706ca80

Please sign in to comment.