Skip to content

Commit

Permalink
Merge pull request #151 from biosimulators/update-lxml
Browse files Browse the repository at this point in the history
lxml doesn't have xpath.execute() any more.
  • Loading branch information
luciansmith authored Feb 16, 2024
2 parents ea6fd5f + 795e370 commit 87d4732
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion biosimulators_utils/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.186'
__version__ = '0.1.187'
2 changes: 1 addition & 1 deletion biosimulators_utils/sedml/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ def validate_target(target, namespaces, context, language, model_id, model_etree
xpath = lxml.etree.XPath(target, namespaces=namespaces)
root = lxml.etree.Element("root")
try:
xpath.evaluate(root)
root.xpath(target, namespaces=namespaces)

if model_etree and check_in_model_source:
if context == DataGenerator and '/@' in target:
Expand Down
13 changes: 3 additions & 10 deletions tests/sedml/test_sedml_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,19 +1318,18 @@ def test_validate_target_xpaths(self):

def test_validate_target(self):
self.assertEqual(validation.validate_target('/sbml:sbml/sbml:model',
{None: 'sed-ml', 'sbml': 'sbml'},
{'sbml': 'sbml'},
data_model.Calculation,
data_model.ModelLanguage.SBML.value,
''), ([], [['XPath could not be validated.']]))
self.assertEqual(validation.validate_target('/sbml:sbml/sbml:model/@sbml:value',
{None: 'sed-ml', 'sbml': 'sbml'},
{'sbml': 'sbml'},
data_model.Calculation,
data_model.ModelLanguage.SBML.value,
''), ([], [['XPath could not be validated.']]))
self.assertEqual(validation.validate_target(
"/sbml:sbml/sbml:model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies[@qual:id='A']/@qual:level",
{
None: 'sed-ml',
'sbml': 'sbml',
'qual': 'qual',
},
Expand All @@ -1341,7 +1340,6 @@ def test_validate_target(self):
self.assertEqual(validation.validate_target(
"/sbml/model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies[@qual:id='A']/@qual:level",
{
None: 'sed-ml',
'sbml': 'sbml',
'qual': 'qual',
},
Expand All @@ -1355,7 +1353,6 @@ def test_validate_target(self):
self.assertEqual(validation.validate_target(
"/sbml:sbml/sbml:model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies[@qual:id='erk']/@qual:compartment",
{
None: 'sed-ml',
'sbml': 'http://www.sbml.org/sbml/level3/version1/core',
'qual': 'http://www.sbml.org/sbml/level3/version1/qual/version1',
},
Expand All @@ -1369,7 +1366,6 @@ def test_validate_target(self):
self.assertEqual(validation.validate_target(
"/sbml:sbml/sbml:model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies[@qual:id='erk']/@qual:level",
{
None: 'sed-ml',
'sbml': 'http://www.sbml.org/sbml/level3/version1/core',
'qual': 'http://www.sbml.org/sbml/level3/version1/qual/version1',
},
Expand All @@ -1382,7 +1378,7 @@ def test_validate_target(self):

self.assertIn('not a valid XML XPath',
flatten_nested_list_of_strings(validation.validate_target('/sbml:sbml@sbml:model',
{None: 'sed-ml', 'sbml': 'sbml'},
{'sbml': 'sbml'},
data_model.Calculation,
data_model.ModelLanguage.SBML.value, '')[0]))
self.assertIn('No namespaces are defined',
Expand All @@ -1400,7 +1396,6 @@ def test_validate_target(self):
flatten_nested_list_of_strings(validation.validate_target(
"/sbml:sbml/sbml:model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies[@qual:id='erk']/@qual:level",
{
None: 'sed-ml',
'sbml': 'http://www.sbml.org/sbml/level3/version1/core',
'qual': 'http://www.sbml.org/sbml/level3/version1/qual/version1',
},
Expand All @@ -1415,7 +1410,6 @@ def test_validate_target(self):
flatten_nested_list_of_strings(validation.validate_target(
"/sbml:sbml/sbml:model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies[@qual:id='ERK']/@qual:compartment",
{
None: 'sed-ml',
'sbml': 'http://www.sbml.org/sbml/level3/version1/core',
'qual': 'http://www.sbml.org/sbml/level3/version1/qual/version1',
},
Expand All @@ -1430,7 +1424,6 @@ def test_validate_target(self):
flatten_nested_list_of_strings(validation.validate_target(
"/sbml:sbml/sbml:model/qual:listOfQualitativeSpecies/qual:qualitativeSpecies",
{
None: 'sed-ml',
'sbml': 'http://www.sbml.org/sbml/level3/version1/core',
'qual': 'http://www.sbml.org/sbml/level3/version1/qual/version1',
},
Expand Down

0 comments on commit 87d4732

Please sign in to comment.