nomad-coe / nomad-parser-plugin-example

This is an example for NOMAD parser plugins. It should be forked to create actual plugins.
Apache License 2.0
6 stars 14 forks source link

Tests point to abs path instead of relative #4

Open JosePizarro3 opened 4 months ago

JosePizarro3 commented 4 months ago

I think some configuration of the tests is wrong. The test should be testing the parse() function of the class itself, without the need to import nomad.client import parse function. I think this client function works matching the parser, or is it implemented such that any parser plugin will be recognized? Also, how optimized this matching would be w.r.t to simply test the class parse() function?

Furthermore, doing this nomad.client.parse creates the need of pointing to the abs path of the tests/data folder, instead of using the relative path. In other words, right now the test config is:

from nomad.client import parse

def test_parser():
    test_file = os.path.join(os.path.dirname(__file__), 'data', 'test.example-format.txt')
    entry_archive = parse(test_file)

but it should be:

from nomadparserexample import ExampleParser

@pytest.fixture(scope='module')
def parser():
    return ExampleParser()

def test_band(parser):
    archive = EntryArchive()
    parser.parse('tests/data/test.example-format.txt', archive, None)
JosePizarro3 commented 4 months ago

@ladinesa