Skip to content

Commit 48bc04b

Browse files
authored
Merge pull request #26 from ProzorroUKR/improvement/item_quantity_float
change Item.quantity type to float
2 parents 325e829 + b5e2f69 commit 48bc04b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/openprocurement/api/models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from schematics.models import Model as SchematicsModel
1515
from schematics.models import ModelMeta
1616
from schematics.transforms import whitelist, blacklist, export_loop, convert
17-
from schematics.types import (StringType, FloatType, URLType, IntType,
18-
BooleanType, BaseType, EmailType, MD5Type, DecimalType as BaseDecimalType)
17+
from schematics.types import (StringType, FloatType, URLType, BooleanType,
18+
BaseType, EmailType, MD5Type, DecimalType as BaseDecimalType)
1919
from schematics.types.compound import (ModelType, DictType,
2020
ListType as BaseListType)
2121
from schematics.types.serializable import serializable
@@ -543,7 +543,7 @@ class Item(Model):
543543
classification = ModelType(CPVClassification)
544544
additionalClassifications = ListType(ModelType(AdditionalClassification), default=list())
545545
unit = ModelType(Unit) # Description of the unit which the good comes in e.g. hours, kilograms
546-
quantity = IntType() # The number of units required
546+
quantity = FloatType() # The number of units required
547547
deliveryDate = ModelType(Period)
548548
deliveryAddress = ModelType(Address)
549549
deliveryLocation = ModelType(Location)
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
from openprocurement.api.models import Item
3+
from openprocurement.api.tests.base import BaseWebTest
4+
import unittest
5+
6+
7+
class ItemTestCase(BaseWebTest):
8+
9+
def test_item_quantity(self):
10+
data = {
11+
"description": "",
12+
"quantity": 12.51,
13+
}
14+
item = Item(data)
15+
item.validate()
16+
self.assertEqual(item.quantity, data["quantity"])
17+
18+
19+
def suite():
20+
suite = unittest.TestSuite()
21+
suite.addTest(unittest.makeSuite(ItemTestCase))
22+
return suite
23+
24+
25+
if __name__ == '__main__':
26+
unittest.main(defaultTest='suite')

0 commit comments

Comments
 (0)