Skip to content

Commit

Permalink
#2513 - Elliptical arrows can not be saved to the png
Browse files Browse the repository at this point in the history
 Add UT
  • Loading branch information
AliaksandrDziarkach committed Nov 14, 2024
1 parent fec30ec commit afad93d
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/tests/integration/ref/rendering/render_reactions.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ issue 2444 wrong arrow and plus width
issue_2444.png rendering status: OK
issue 2512 two short equilibrium half arrows
issue_2512.png rendering status: OK
issue 2513 elliptical-arc-arrow render error
issue_2513.png rendering status: OK
102 changes: 102 additions & 0 deletions api/tests/integration/tests/rendering/reactions/issue_2513.ket
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"root": {
"nodes": [
{
"$ref": "mol0"
},
{
"$ref": "mol1"
},
{
"$ref": "mol2"
},
{
"type": "arrow",
"data": {
"mode": "elliptical-arc-arrow-open-angle",
"pos": [
{
"x": 5.799999999999997,
"y": -8.200000000000003,
"z": 0
},
{
"x": 7.205569279687058,
"y": -8.200000000000003,
"z": 0
}
],
"height": 1
}
},
{
"type": "arrow",
"data": {
"mode": "open-angle",
"pos": [
{
"x": 7.775,
"y": -8.225,
"z": 0
},
{
"x": 8.875,
"y": -8.225,
"z": 0
}
]
}
},
{
"type": "plus",
"location": [
6.525,
-8.225,
0
],
"prop": {}
}
],
"connections": [],
"templates": []
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "N",
"location": [
5.749999999999999,
-8.350000000000001,
0
]
}
]
},
"mol1": {
"type": "molecule",
"atoms": [
{
"label": "O",
"location": [
7.3999999999999995,
-8.3,
0
]
}
]
},
"mol2": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
9.15,
-8.3,
0
]
}
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions api/tests/integration/tests/rendering/render_reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ def renderRxnfile(filename, outfile):
renderer.renderToFile(rxn, joinPathPy("out/" + png_fname, __file__))
print(checkImageSimilarity(png_fname))

print("issue 2513 elliptical-arc-arrow render error")
indigo.resetOptions()
indigo.setOption("ignore-stereochemistry-errors", "true")
indigo.setOption("render-background-color", "255, 255, 255")
indigo.setOption("render-output-format", "png")
fname = "issue_2513"
png_fname = fname + ".png"
ket_fname = joinPathPy("reactions/%s.ket" % fname, __file__)
rxn = indigo.loadReactionFromFile(ket_fname)
renderer.renderToFile(rxn, joinPathPy("out/" + png_fname, __file__))
print(checkImageSimilarity(png_fname))

if isIronPython():
renderer.Dispose()
indigo.Dispose()
123 changes: 123 additions & 0 deletions utils/indigo-service/backend/service/tests/api/indigo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,129 @@ def test_check_overlap(self):
result_data["overlapping_atoms"],
)

def test_render_eleptical_arrow(self):

ket = """{
"root": {
"nodes": [
{
"$ref": "mol0"
},
{
"$ref": "mol1"
},
{
"$ref": "mol2"
},
{
"type": "arrow",
"data": {
"mode": "elliptical-arc-arrow-open-angle",
"pos": [
{
"x": 5.799999999999997,
"y": -8.200000000000003,
"z": 0
},
{
"x": 7.205569279687058,
"y": -8.200000000000003,
"z": 0
}
],
"height": 1
}
},
{
"type": "arrow",
"data": {
"mode": "open-angle",
"pos": [
{
"x": 7.775,
"y": -8.225,
"z": 0
},
{
"x": 8.875,
"y": -8.225,
"z": 0
}
]
}
},
{
"type": "plus",
"location": [
6.525,
-8.225,
0
],
"prop": {}
}
],
"connections": [],
"templates": []
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "N",
"location": [
5.749999999999999,
-8.350000000000001,
0
]
}
]
},
"mol1": {
"type": "molecule",
"atoms": [
{
"label": "O",
"location": [
7.3999999999999995,
-8.3,
0
]
}
]
},
"mol2": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
9.15,
-8.3,
0
]
}
]
}
}"""
ref_path = joinPathPy("ref/", __file__)
headers, data = self.get_headers(
{
"output_format": "image/png",
"struct": ket,
}
)
result = requests.post(
self.url_prefix + "/render",
headers=headers,
data=data,
)
fname = "render-eleptical-arrow.png"
with open(os.path.join(ref_path, fname), "wb") as file:
file.write(result.content)
with open(os.path.join(ref_path, fname), "rb") as file:
ref = file.read()
self.assertEqual(result.content, ref)

def test_check_stereo(self):
# up
headers, data = self.get_headers(
Expand Down

0 comments on commit afad93d

Please sign in to comment.