From 597d71be9efe942b5c2da2068d46f43c56d16ae9 Mon Sep 17 00:00:00 2001 From: "Guillem Pozo S." Date: Mon, 15 Jun 2026 16:41:30 +0200 Subject: [PATCH 1/2] consider flag punt frontera for pos 5 codification --- cini/models.py | 24 ++++++++++++++---------- spec/cts_spec.py | 5 +++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/cini/models.py b/cini/models.py index e32adf0..be4b196 100644 --- a/cini/models.py +++ b/cini/models.py @@ -367,6 +367,7 @@ def __init__(self): - Móvil = ``M`` """ self.tipo = None + self.punt_frontera = False self.transformadores = [] # Lista de transformadores del CT @property @@ -403,16 +404,19 @@ def cini(self): if self.tension_s is not None and self.tension_s < 1: c.positions[4] = '5' - if self.tipo == 'I': - c.positions[5] = '1' - elif self.tipo == 'C': - c.positions[5] = '2' - elif self.tipo == 'L': - c.positions[5] = '3' - elif self.tipo == 'S': - c.positions[5] = '4' - elif self.tipo == 'M': - c.positions[5] = '9' + if self.punt_frontera: + c.positions[5] = '5' + else: + if self.tipo == 'I': + c.positions[5] = '1' + elif self.tipo == 'C': + c.positions[5] = '2' + elif self.tipo == 'L': + c.positions[5] = '3' + elif self.tipo == 'S': + c.positions[5] = '4' + elif self.tipo == 'M': + c.positions[5] = '9' if self.tension is not None: if self.tension <= 1: diff --git a/spec/cts_spec.py b/spec/cts_spec.py index ed978f1..d735b2e 100644 --- a/spec/cts_spec.py +++ b/spec/cts_spec.py @@ -63,6 +63,11 @@ self.ct.tipo = 'M' cini = self.ct.cini expect(cini[5]).to(equal('9')) + with context('si te flag Punt frontera, ignora tipo'): + with it('must be 5'): + self.ct.punt_frontera = True + cini = self.ct.cini + expect(cini[5]).to(equal('5')) with description('la sexta posicion'): with before.all: From 0dcae665f1b40f8fcb05fb12c924174d1e734354 Mon Sep 17 00:00:00 2001 From: "Guillem Pozo S." Date: Mon, 15 Jun 2026 16:58:28 +0200 Subject: [PATCH 2/2] refactor: avoid shared context in tests and add in punt frontera attribute --- cini/models.py | 2 +- spec/cts_spec.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cini/models.py b/cini/models.py index be4b196..5db2e98 100644 --- a/cini/models.py +++ b/cini/models.py @@ -367,7 +367,7 @@ def __init__(self): - Móvil = ``M`` """ self.tipo = None - self.punt_frontera = False + self.punt_frontera = False # Si True, la 5a posició del CINI es '5' (Punt Frontera) self.transformadores = [] # Lista de transformadores del CT @property diff --git a/spec/cts_spec.py b/spec/cts_spec.py index d735b2e..bce949b 100644 --- a/spec/cts_spec.py +++ b/spec/cts_spec.py @@ -63,9 +63,10 @@ self.ct.tipo = 'M' cini = self.ct.cini expect(cini[5]).to(equal('9')) - with context('si te flag Punt frontera, ignora tipo'): - with it('must be 5'): + with context('si es Punt Frontera'): + with it('sobreescriu el tipo i val 5'): self.ct.punt_frontera = True + self.ct.tipo = 'I' cini = self.ct.cini expect(cini[5]).to(equal('5'))