import pytest from geomagio.edge import FDSNSNCL from geomagio.edge.FDSNSNCL import get_FDSN_channel, get_location def test_data_type(): """edge_test.IRISSNCL_test.test_data_type()""" assert ( FDSNSNCL(station="ANMO", network="IU", channel="LF1", location="40").data_type == "variation" ) def test_element(): """edge_test.FDSNSNCL_test.test_element()""" assert ( FDSNSNCL(station="ANMO", network="IU", channel="LF1", location="40").element == "V" ) assert ( FDSNSNCL(station="ANMO", network="IU", channel="LF2", location="40").element == "U" ) assert ( FDSNSNCL(station="ANMO", network="IU", channel="LFZ", location="40").element == "W" ) with pytest.raises(ValueError) as error: FDSNSNCL(station="ANMO", network="IU", channel="LFH", location="40").element assert error.value == "Unsupported channel LFH" def test_get_FDSN_channel(): """edge_test.FDSNSNCL_test.test_get_FDSN_channel()""" assert ( get_FDSN_channel( element="E", interval="second", data_type="variation", network="IU", location="40", ) == "LF1" ) assert ( get_FDSN_channel( element="V", interval="second", data_type="variation", network="IU", location="40", ) == "LF1" ) assert ( get_FDSN_channel( element="H", interval="second", data_type="variation", network="IU", location="40", ) == "LF2" ) assert ( get_FDSN_channel( element="U", interval="second", data_type="variation", network="IU", location="40", ) == "LF2" ) assert ( get_FDSN_channel( element="W", interval="second", data_type="variation", network="IU", location="40", ) == "LFZ" ) # predefined channel assert ( get_FDSN_channel( element="LFZ", interval="second", data_type="variation", network="IU", location="40", ) == "LFZ" ) with pytest.raises(ValueError) as error: get_FDSN_channel( element="D", interval="second", data_type="variation", network="IU", location="40", ) assert error.value == "Unsupported element: D" def test_get_sncl(): """edge_test.IRISSNCL_test.test_get_sncl()""" assert FDSNSNCL.get_sncl( data_type="variation", element="H", interval="second", station="ANMO", network="IU", location="40", ) == FDSNSNCL(station="ANMO", network="IU", channel="LF2", location="40") with pytest.raises(ValueError) as error: FDSNSNCL.get_sncl( data_type="adjusted", element="H", interval="second", station="ANMO", network="IU", location="40", ) assert error.value == "Unsupported data type: adjusted" assert FDSNSNCL.get_sncl( data_type="adjusted", element="H", interval="second", station="ANMO", ) == FDSNSNCL(station="ANMO", network="NT", channel="LFH", location="40") assert error.value == "Unsupported data type: adjusted" def test_interval(): """edge_test.FDSNSNCL_test.test_interval()""" assert ( FDSNSNCL( station="ANMO", network="IU", channel="LF1", location="40", ).interval == "second" ) def test_parse_sncl(): """edge_test.FDSNSNCL_test.test_parse_sncl()""" assert FDSNSNCL( station="ANMO", network="IU", channel="LF1", location="40" ).parse_sncl() == { "station": "ANMO", "network": "IU", "data_type": "variation", "element": "V", "interval": "second", }