Skip to content

Commit 92eed42

Browse files
committed
review : resolving review comments by zaeema
1 parent 156be66 commit 92eed42

2 files changed

Lines changed: 40 additions & 22 deletions

File tree

opengin/tests/e2e/basic_core_tests.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,17 @@ def create_minister_with_attributes(self):
683683
def read_minister(self):
684684
"""Read the Minister entity."""
685685
print("\n🟢 Reading Minister entity...")
686-
res = requests.get(f"{self.base_url}/{self.MINISTER_ID}")
686+
payload = {
687+
"id": self.MINISTER_ID
688+
}
689+
res = requests.post(f"{self.base_read_url}/search", json=payload)
687690
print(res.status_code, res.json())
688691
assert res.status_code in [200], f"Failed to read Minister: {res.text}"
689692

690693
# Verify the response data
691694
response_data = res.json()
695+
response_data = response_data["body"][0]
696+
692697
print(response_data)
693698
assert response_data["id"] == self.MINISTER_ID, (
694699
f"Expected ID {self.MINISTER_ID}, got {response_data['id']}"
@@ -702,9 +707,16 @@ def read_minister(self):
702707
assert response_data["created"] == self.START_DATE, (
703708
f"Expected created date {self.START_DATE}, got {response_data['created']}"
704709
)
710+
711+
print("im here befire you bitchhhhh....")
712+
705713
# The name value is a protobuf Any that needs to be decoded
706-
name_value = response_data["name"]["value"]
707-
decoded_name = CoreTestUtils.decode_protobuf_string_value(name_value)
714+
print("i am here..............")
715+
name_obj = json.loads(response_data["name"])
716+
print(name_obj)
717+
hex_value = name_obj["value"]
718+
print(hex_value)
719+
decoded_name = bytes.fromhex(hex_value).decode('utf-8')
708720
assert decoded_name == "Minister of Finance and Economy", (
709721
f"Expected name 'Minister of Finance and Economy', got {decoded_name}"
710722
)
@@ -850,7 +862,7 @@ def create_minister_with_attributes_with_startDate_and_endDate(self):
850862

851863
print("\n🟢 checking Minister with attribute with startDate and endDate...")
852864

853-
url = f"{self.base_read_url}/v1/entities/{self.MINISTER_ID}/attributes/{self.ATTRIBUTE_NAME_2}"
865+
url = f"{self.base_read_url}/{self.MINISTER_ID}/attributes/{self.ATTRIBUTE_NAME_2}"
854866
payload = {}
855867

856868
res = requests.post(url, json=payload)
@@ -884,24 +896,23 @@ def create_minister_with_attributes_with_startDate_and_endDate(self):
884896

885897
print("Decoded value: ", decoded_value)
886898

887-
url = f"{self.base_url}/{self.MINISTER_ID}"
899+
url = f"{self.base_read_url}/{self.MINISTER_ID}/relations"
900+
payload = {}
888901

889-
res = requests.get(url)
902+
res = requests.post(url, json=payload)
890903
print(res.status_code, res.json())
891-
assert res.status_code in [200], f"Failed to read Minister: {res.text}"
892-
893-
response_data = res.json()
894-
print(response_data)
904+
assert res.status_code in [200], f"Failed to read Minister relationships: {res.text}"
895905

896-
relationships = response_data["relationships"]
906+
relationships = res.json()
907+
print(relationships)
897908

898909
print("relationships", relationships)
899910

900911
# check for the start data and the end date
901912
for relationship in relationships:
902-
if relationship["value"]["startTime"] != "" and relationship["value"]["endTime"] != "":
903-
assert relationship["value"]["startTime"] == self.DATA_START_DATE
904-
assert relationship["value"]["endTime"] == self.DATA_END_DATE
913+
if relationship["startTime"] != "" and relationship["endTime"] != "":
914+
assert relationship["startTime"] == self.DATA_START_DATE
915+
assert relationship["endTime"] == self.DATA_END_DATE
905916
else:
906917
pass
907918

@@ -1065,7 +1076,7 @@ def get_base_read_url():
10651076
print("🟢 Setting up test environment...")
10661077
read_service_url = os.getenv("READ_SERVICE_URL", "http://read:8081")
10671078
print("🟢 READ_SERVICE_URL: ", read_service_url)
1068-
return read_service_url
1079+
return f"{read_service_url}/v1/entities"
10691080

10701081

10711082
# Tabular Attribute Integrity Tests

opengin/tests/e2e/basic_read_tests.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,14 +834,21 @@ def create_entity_for_read():
834834
relationships = response_data["relationships"]
835835
print(relationships)
836836

837-
# check for the start date and the end date
837+
found = False
838+
838839
for relationship in relationships:
839-
if relationship["value"]["startTime"] != "" and relationship["value"]["endTime"] != "":
840-
assert relationship["value"]["startTime"] in ["2024-11-01T00:00:00Z", "2024-01-01T00:00:00Z"]
841-
assert relationship["value"]["endTime"] in ["2024-11-30T00:00:00Z","2024-12-31T23:59:59Z"]
842-
else:
843-
pass
844-
print("✅ Verified start and end times.")
840+
start = relationship["value"].get("startTime")
841+
end = relationship["value"].get("endTime")
842+
843+
if start and end:
844+
found = True
845+
846+
assert start in ["2024-11-01T00:00:00Z", "2024-01-01T00:00:00Z"]
847+
assert end in ["2024-11-30T00:00:00Z", "2024-12-31T23:59:59Z"]
848+
849+
assert found, "No relationship found with both startTime and endTime"
850+
851+
print("✅ Verified start and end times of entity's attributes.")
845852

846853
def test_attribute_fields_combinations():
847854
"""Test different field combinations for attribute retrieval."""

0 commit comments

Comments
 (0)