| Total Complexity | 7 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import pytest |
||
| 2 | import amd |
||
| 3 | |||
| 4 | |||
| 5 | @pytest.fixture(scope="module") |
||
| 6 | def refcode_families(): |
||
| 7 | return ["DEBXIT", "GLYCIN", "HXACAN", "ACSALA"] |
||
| 8 | |||
| 9 | |||
| 10 | def test_CSDReader(reference_data, refcode_families, ccdc_enabled): |
||
| 11 | if not ccdc_enabled: |
||
| 12 | pytest.skip("Skipping test_CSDReader as csd-python-api failed to import.") |
||
| 13 | |||
| 14 | references = reference_data["CSD_families"] |
||
| 15 | read_in = amd.CSDReader( |
||
| 16 | refcode_families, show_warnings=False, refcode_families=True |
||
| 17 | ).read() |
||
| 18 | |||
| 19 | if (len(references) != len(read_in)) or len(read_in) == 0: |
||
| 20 | pytest.fail( |
||
| 21 | f"There are {len(references)} references, but {len(read_in)} " |
||
| 22 | "structures were read." |
||
| 23 | ) |
||
| 24 | |||
| 25 | for s, s_ in zip(read_in, references): |
||
| 26 | if not s._equal_cell_and_motif(s_["PeriodicSet"]): |
||
| 27 | s1 = str(s) |
||
| 28 | s2 = str(s_["PeriodicSet"]) |
||
| 29 | pytest.fail( |
||
| 30 | f"Structure {s.name} is different from reference; " |
||
| 31 | f"Reference: {s2}, read with CSDReader: {s1}." |
||
| 33 |