Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cini/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,12 @@ class Fiabilidad(Base):
'P': '2'
}

TIPO_INTERRUPTORES = {
'0': '2',
'1': '2',
'2': '3'
}

SITUACIONES = {
'SE': '1',
'CT': '2',
Expand All @@ -820,6 +826,7 @@ def __init__(self):
self.tension = None
self.tipo = None
self.tipo_posicion = None
self.tipo_interruptor = None
self.telemando = None
self.situacion = None
self.aislante = None
Expand All @@ -843,8 +850,9 @@ def cini(self):
c.positions[3] = self.TENSIONES[self.situacion][1]
elif 1 <= self.tension < 36:
c.positions[3] = self.TENSIONES[self.situacion][2]
if self.situacion in ('CT', 'SE'):
c.positions[4] = '2'
if self.situacion in ('CT', 'SE') and self.tipo_interruptor:
c.positions[4] = (
self.TIPO_INTERRUPTORES.get(self.tipo_interruptor, '2'))
else:
c.positions[4] = '0'
if self.situacion == 'LAT' and self.tipo:
Expand Down
38 changes: 26 additions & 12 deletions spec/fiabilidad_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,36 @@
expect(cini[3]).to(equal('C'))

with description('la cuarta posición'):
with before.all:
self.fiab = Fiabilidad()
with context('Si está en un CT'):
with it('must be 2'):
l = Fiabilidad()
l.situacion = 'CT'
l.tipo = 'S'
cini = l.cini
expect(cini[4]).to(equal('2'))
self.fiab.situacion = 'CT'
self.fiab.tipo = 'S'
for int in ['0', '1']:
self.fiab.tipo_interruptor = int
cini = self.fiab.cini
expect(cini[4]).to(equal('2'))
with it('must be 3'):
self.fiab.situacion = 'CT'
self.fiab.tipo = 'S'
self.fiab.tipo_interruptor = '2'
cini = self.fiab.cini
expect(cini[4]).to(equal('3'))
with context('Si está en una SE'):
with it('must be 2'):
l = Fiabilidad()
l.situacion = 'SE'
l.tipo = 'R'
cini = l.cini
expect(cini[4]).to(equal('2'))
with before.all:
self.fiab = Fiabilidad()
self.fiab.situacion = 'SE'
self.fiab.tipo = 'R'
for int in ['0', '1']:
self.fiab.tipo_interruptor = int
cini = self.fiab.cini
expect(cini[4]).to(equal('2'))
with it('must be 3'):
self.fiab.situacion = 'SE'
self.fiab.tipo = 'R'
self.fiab.tipo_interruptor = '2'
cini = self.fiab.cini
expect(cini[4]).to(equal('3'))
with it('must be 0'):
cini = self.fiab.cini
expect(cini[4]).to(equal('0'))
Expand Down
Loading