summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lesana/collection.py2
-rw-r--r--tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml3
-rw-r--r--tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml2
-rw-r--r--tests/data/simple/settings.yaml10
-rw-r--r--tests/data/wrong/items/b9a832309c984ada9f267471660c1313.yaml2
-rw-r--r--tests/data/wrong/settings.yaml6
-rw-r--r--tests/test_collection.py8
7 files changed, 27 insertions, 6 deletions
diff --git a/lesana/collection.py b/lesana/collection.py
index 8b27f01..d198ef0 100644
--- a/lesana/collection.py
+++ b/lesana/collection.py
@@ -115,7 +115,7 @@ class Entry(object):
elif t == 'decimal':
try:
decimal.Decimal(value)
- except ValueError:
+ except decimal.InvalidOperation:
valid = False
errors.append({
'field': field['name'],
diff --git a/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml b/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml
index 0abc78d..99431b1 100644
--- a/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml
+++ b/tests/data/simple/items/085682ed-6792-499d-a3ab-9aebd683c011.yaml
@@ -3,4 +3,7 @@ description: |
This is a long block of text
that spans multiple lines.
position: somewhere
+quantity: 2
+value: 0.8
+cost: 1.99
eid: 085682ed6792499da3ab9aebd683c011
diff --git a/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml b/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml
index 7a0f5d7..d64a7c2 100644
--- a/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml
+++ b/tests/data/simple/items/8b69b063b2a64db7b5714294a69255c7.yaml
@@ -2,4 +2,6 @@ name: 'Mostly empty entry'
description:
position:
quantity:
+amount:
+price:
other:
diff --git a/tests/data/simple/settings.yaml b/tests/data/simple/settings.yaml
index ad68fe3..1852665 100644
--- a/tests/data/simple/settings.yaml
+++ b/tests/data/simple/settings.yaml
@@ -9,11 +9,19 @@ fields:
index: free
- name: position
type: string
- index: facet
+ index: field
- name: quantity
type: integer
index: no
help: 'how many items are there'
+ - name: value
+ type: float
+ index: no
+ help: 'how much each item is'
+ - name: cost
+ type: decimal
+ index: no
+ help: 'how much this costs'
- name: other
type: yaml
help: ''
diff --git a/tests/data/wrong/items/b9a832309c984ada9f267471660c1313.yaml b/tests/data/wrong/items/b9a832309c984ada9f267471660c1313.yaml
index ec44b7c..b36cc4e 100644
--- a/tests/data/wrong/items/b9a832309c984ada9f267471660c1313.yaml
+++ b/tests/data/wrong/items/b9a832309c984ada9f267471660c1313.yaml
@@ -3,3 +3,5 @@ description: |
.
position: 'somewhere'
number: 'four'
+float: 'half and a bit'
+price: 'cheap'
diff --git a/tests/data/wrong/settings.yaml b/tests/data/wrong/settings.yaml
index ef9ab74..243ab62 100644
--- a/tests/data/wrong/settings.yaml
+++ b/tests/data/wrong/settings.yaml
@@ -12,3 +12,9 @@ fields:
- name: number
type: integer
help: "Enter an integer here"
+ - name: float
+ type: float
+ help: "Enter a floating point number here"
+ - name: price
+ type: decimal
+ help: 'prices are never float!'
diff --git a/tests/test_collection.py b/tests/test_collection.py
index b5266d9..798e561 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -28,8 +28,8 @@ class testCollection(unittest.TestCase):
self.collection.settings['name'],
"Simple lesana collection"
)
- self.assertEqual(len(self.collection.settings['fields']), 5)
- self.assertEqual(len(self.collection.indexed_fields), 2)
+ self.assertEqual(len(self.collection.settings['fields']), 7)
+ self.assertEqual(len(self.collection.indexed_fields), 3)
self.collection.update_cache()
self.assertIsNotNone(self.collection.stemmer)
@@ -54,7 +54,7 @@ class testCollection(unittest.TestCase):
self.assertIsNotNone(self.collection.settings)
self.assertIsNotNone(self.collection.stemmer)
# Fields with no "index" entry are not indexed
- self.assertEqual(len(self.collection.settings['fields']), 4)
+ self.assertEqual(len(self.collection.settings['fields']), 6)
self.assertEqual(len(self.collection.indexed_fields), 1)
def test_load_safe(self):
@@ -326,7 +326,7 @@ class testCollectionWithErrors(unittest.TestCase):
self.collection.settings['name'],
"Lesana collection with certain errors"
)
- self.assertEqual(len(self.collection.settings['fields']), 4)
+ self.assertEqual(len(self.collection.settings['fields']), 6)
self.assertIsNotNone(self.collection.stemmer)
self.assertEqual(len(self.collection.indexed_fields), 1)