Skip to content

Commit

Permalink
Merge pull request #26 from ProzorroUKR/improvement/item_quantity_float
Browse files Browse the repository at this point in the history
change  Item.quantity type to float
  • Loading branch information
dimka2014 authored Feb 18, 2019
2 parents 325e829 + b5e2f69 commit 48bc04b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/openprocurement/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from schematics.models import Model as SchematicsModel
from schematics.models import ModelMeta
from schematics.transforms import whitelist, blacklist, export_loop, convert
from schematics.types import (StringType, FloatType, URLType, IntType,
BooleanType, BaseType, EmailType, MD5Type, DecimalType as BaseDecimalType)
from schematics.types import (StringType, FloatType, URLType, BooleanType,
BaseType, EmailType, MD5Type, DecimalType as BaseDecimalType)
from schematics.types.compound import (ModelType, DictType,
ListType as BaseListType)
from schematics.types.serializable import serializable
Expand Down Expand Up @@ -543,7 +543,7 @@ class Item(Model):
classification = ModelType(CPVClassification)
additionalClassifications = ListType(ModelType(AdditionalClassification), default=list())
unit = ModelType(Unit) # Description of the unit which the good comes in e.g. hours, kilograms
quantity = IntType() # The number of units required
quantity = FloatType() # The number of units required
deliveryDate = ModelType(Period)
deliveryAddress = ModelType(Address)
deliveryLocation = ModelType(Location)
Expand Down
26 changes: 26 additions & 0 deletions src/openprocurement/api/tests/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
from openprocurement.api.models import Item
from openprocurement.api.tests.base import BaseWebTest
import unittest


class ItemTestCase(BaseWebTest):

def test_item_quantity(self):
data = {
"description": "",
"quantity": 12.51,
}
item = Item(data)
item.validate()
self.assertEqual(item.quantity, data["quantity"])


def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ItemTestCase))
return suite


if __name__ == '__main__':
unittest.main(defaultTest='suite')

0 comments on commit 48bc04b

Please sign in to comment.