import numpy as np
import nmrglue as ng

from dp5.nmr_processing.helper_functions import read_jcamp, read_bruker
file_2d = '/home/rk582/DP5/test/isasfid1.dx'
file_1d = '/home/rk582/DP5/test/TESTFID.DX'
bruker_1d = '/home/rk582/DP5/test/TPS-1-14/99'

nucleus, ydata, uc = read_jcamp(file_1d)
assert nucleus == '13C'
assert type(ydata) == np.ndarray
assert type(uc) == ng.fileio.fileiobase.unit_conversion
# Must crash on multidimensional data
try:
    dic, ydata = read_jcamp(file_2d)
    raise AssertionError('nmrglue does not support multidomensional data')
except UserWarning:
    pass
print('JCAMP files read successfully')

nucleus, ydata, uc = read_bruker(bruker_1d)
assert nucleus == '1H'
assert type(ydata) == np.ndarray
assert type(uc) == ng.fileio.fileiobase.unit_conversion
print('Bruker files read sucessfully')
