66import pytest
77import os
88import tempfile
9- from pvlib .iotools import read_bsrn , get_bsrn
9+ from pvlib .iotools import read_bsrn , get_bsrn , parse_bsrn
1010from tests .conftest import (
1111 TESTS_DATA_DIR ,
1212 RERUNS ,
1515 requires_bsrn_credentials ,
1616)
1717
18+ from pvlib ._deprecation import pvlibDeprecationWarning
1819
1920@pytest .fixture (scope = "module" )
2021def bsrn_credentials ():
@@ -33,6 +34,12 @@ def expected_index():
3334 tz = 'UTC' )
3435
3536
37+ def test_parse_bsrn_deprecated ():
38+ with pytest .warns (pvlibDeprecationWarning , match = 'Use read_bsrn instead' ):
39+ with open (TESTS_DATA_DIR / 'bsrn-lr0100-pay0616.dat' ) as fbuf :
40+ data , metadata = parse_bsrn (fbuf )
41+
42+
3643@pytest .mark .parametrize ('testfile' , [
3744 ('bsrn-pay0616.dat.gz' ),
3845 ('bsrn-lr0100-pay0616.dat' ),
@@ -47,6 +54,17 @@ def test_read_bsrn(testfile, expected_index):
4754 assert 'relative_humidity' in data .columns
4855
4956
57+ def test_read_bsrn_buffer (expected_index ):
58+ with open (TESTS_DATA_DIR / 'bsrn-lr0100-pay0616.dat' ) as fbuf :
59+ data , metadata = read_bsrn (fbuf )
60+ assert_index_equal (expected_index , data .index )
61+ assert 'ghi' in data .columns
62+ assert 'dni_std' in data .columns
63+ assert 'dhi_min' in data .columns
64+ assert 'lwd_max' in data .columns
65+ assert 'relative_humidity' in data .columns
66+
67+
5068def test_read_bsrn_logical_records (expected_index ):
5169 # Test if logical records 0300 and 0500 are correct parsed
5270 # and that 0100 is not passed when not specified
0 commit comments