Skip to content

Commit

Permalink
Add reganecu and reganecuqh tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmunoznovoa committed Oct 18, 2024
1 parent 835d8fe commit 18e3ca6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cchloader/parsers/reganecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

class Reganecu(Parser):

patterns = ['^reganecu_']
patterns = ['^([ABC])(\d{1})_reganecu_',
'^reganecu_']
encoding = "iso-8859-15"
delimiter = ';'

Expand Down
3 changes: 2 additions & 1 deletion cchloader/parsers/reganecuqh.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

class ReganecuQh(Parser):

patterns = ['^_reganecuqh_']
patterns = ['^([ABC])(\d{1})_reganecuqh_',
'^reganecuqh_']
encoding = "iso-8859-15"
delimiter = ';'

Expand Down
38 changes: 38 additions & 0 deletions spec/test_parsers_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from cchloader.parsers.medidas import Medidas
from cchloader.parsers.corbagen import CorbaGen
from cchloader.parsers.infpa import Infpa
from cchloader.parsers.reganecu import Reganecu
from cchloader.parsers.reganecuqh import ReganecuQh
from cchloader.exceptions import ParserNotFoundException
from cchloader.file import PackedCchFile, CchFile

Expand Down Expand Up @@ -56,6 +58,12 @@
self.corbagen_filenames = [
'CORBAGEN_202403.0' # Documented
]
self.reganecu_filenames = [
'C3_reganecu_20240501_demo' # Documented
]
self.reganecuqh_filenames = [
'C3_reganecuqh_20240501_demo' # Documented
]
self.wrong_filename = 'P1_20170507_20170706.6'
self.infpa_filenames = [
'INFPA_H3_1234_P2_202401.0.bz2' # Documented
Expand Down Expand Up @@ -178,6 +186,36 @@
assert result_corbagen == expected_corbagen
break

with it('test to get REGANECU parser'):
for filename in self.reganecu_filenames:
expect(get_parser(filename)).to(equal(Reganecu))
with it('REGANECU parser fits file format'):
with CchFile('spec/curve_files/C3_reganecu_20240501_demo') as cch_file:
l = 1
for line in cch_file:
if l < 3:
l += 1
continue
expected_reganecu = '01/05/2024;6;DEMO_RE;0.014;;1.5042;;0.02;;;BS3;3;;C_BAN;-1;0;18X0000000004444;DSV;P_2BAN;P_3CBAN_OP;R;11;0;0;\r\n'
result_reganecu = line['orig']
assert result_reganecu == expected_reganecu
break

with it('test to get REGANECUQH parser'):
for filename in self.reganecuqh_filenames:
expect(get_parser(filename)).to(equal(ReganecuQh))
with it('REGANECUQH parser fits file format'):
with CchFile('spec/curve_files/C3_reganecuqh_20240501_demo') as cch_file:
l = 1
for line in cch_file:
if l < 3:
l += 1
continue
expected_reganecu = '01/05/2024 00:00;;DEMO_RE;0.014;;1.5042;;0.02;;;BS3;3;;C_BAN;-1;0;18X0000000004444;DSV;P_2BAN;P_3CBAN_OP;R;11;0;;\r\n'
result_reganecu = line['orig']
assert result_reganecu == expected_reganecu
break

with it('test to get INFPA parser'):
for filename in self.infpa_filenames:
expect(get_parser(filename)).to(equal(Infpa))
Expand Down

0 comments on commit 18e3ca6

Please sign in to comment.