Skip to content

Commit

Permalink
Arreglar bug update curve rep un enter a producció (#5)
Browse files Browse the repository at this point in the history
* Fix update curve receives an int in production

* Bump to 1.7.8
  • Loading branch information
oriolpiera committed Nov 23, 2023
1 parent e1778b5 commit 4be35d1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plantmeter/mongotimecurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def update(self, start, filter, field, data):
assert start.tzinfo is not None, (
"MongoTimeCurve.update called with naive (no timezone) start date")

if isinstance(filter, str):
if isinstance(filter, str) or isinstance(filter, int):
filter = dict(name=filter)

stop = start + datetime.timedelta(days=len(data)//hoursPerDay+1)
Expand Down
38 changes: 38 additions & 0 deletions plantmeter/mongotimecurve_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ def test_get_withSingleData(self):
list(curve),
[0]*23+[10,0])

def test_get_intAsFilter(self):
mtc = self.curve()
curve = mtc.get(
start=localisodate('2015-01-01'),
stop=localisodate('2015-01-01'),
filter=1,
field='usage_kwh',
)
self.assertEqual(
list(curve),
[0]*25)

def test_get_twoDays(self):
mtc = self.setupPoints([
('2015-01-01 23:00:00', 'miplanta', 10),
Expand Down Expand Up @@ -765,6 +777,32 @@ def test_update_numpyData(self):
+24*[True]+[False]
)

def test_update_intAsFilter(self):
mtc = self.setupPoints([])

curve = mtc.update(
start=localisodate('2015-08-15'),
filter=1,
field='usage_kwh',
data=+25*[1]
)
curve, filling = mtc.get(
start=localisodate('2015-08-15'),
stop=localisodate('2015-08-15'),
filter=1,
field='usage_kwh',
filling=True,
)
self.assertEqual(
list(curve),
+24*[1]+[0]
)
self.assertEqual(
list(filling),
+24*[True]+[False]
)


class MongoTimeCurveNew_Test(MongoTimeCurve_Test):
def curve(self):
return MongoTimeCurve(self.db, self.collection,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name = "plantmeter",
version = "1.7.7",
version = "1.7.8",
description =
"OpenERP module and library to manage multisite energy generation",
author = "Som Energia SCCL",
Expand Down

0 comments on commit 4be35d1

Please sign in to comment.