--- a/server/test/data/schema.py Fri Aug 06 17:49:20 2010 +0200
+++ b/server/test/data/schema.py Tue Aug 10 08:28:16 2010 +0200
@@ -17,7 +17,8 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
- SubjectRelation, RichString, String, Int, Boolean, Datetime)
+ SubjectRelation, RichString, String, Int, Float,
+ Boolean, Datetime)
from yams.constraints import SizeConstraint
from cubicweb.schema import (WorkflowableEntityType, RQLConstraint,
ERQLExpression, RRQLExpression)
@@ -39,7 +40,7 @@
description=_('more detailed description'))
duration = Int()
- invoiced = Int()
+ invoiced = Float()
depends_on = SubjectRelation('Affaire')
require_permission = SubjectRelation('CWPermission')
--- a/server/test/unittest_msplanner.py Fri Aug 06 17:49:20 2010 +0200
+++ b/server/test/unittest_msplanner.py Tue Aug 10 08:28:16 2010 +0200
@@ -1866,7 +1866,7 @@
[('FetchStep', [('Any WP WHERE 999999 multisource_rel WP, WP is Note', [{'WP': 'Note'}])],
[self.cards], None, {'WP': u'table0.C0'}, []),
('OneFetchStep', [('Any S,SUM(DUR),SUM(I),(SUM(I) - SUM(DUR)),MIN(DI),MAX(DI) GROUPBY S ORDERBY S WHERE A duration DUR, A invoiced I, A modification_date DI, A in_state S, S name SN, (EXISTS(A concerne WP, WP is Note)) OR (EXISTS(A concerne 999999)), A is Affaire, S is State',
- [{'A': 'Affaire', 'DI': 'Datetime', 'DUR': 'Int', 'I': 'Int', 'S': 'State', 'SN': 'String', 'WP': 'Note'}])],
+ [{'A': 'Affaire', 'DI': 'Datetime', 'DUR': 'Int', 'I': 'Float', 'S': 'State', 'SN': 'String', 'WP': 'Note'}])],
None, None, [self.system], {'WP': u'table0.C0'}, [])],
{'n': 999999})
--- a/server/test/unittest_querier.py Fri Aug 06 17:49:20 2010 +0200
+++ b/server/test/unittest_querier.py Tue Aug 10 08:28:16 2010 +0200
@@ -544,12 +544,25 @@
self.assertEquals(rset.rows[0][0], 'ADMIN')
self.assertEquals(rset.description, [('String',)])
-## def test_select_simplified(self):
-## ueid = self.session.user.eid
-## rset = self.execute('Any L WHERE %s login L'%ueid)
-## self.assertEquals(rset.rows[0][0], 'admin')
-## rset = self.execute('Any L WHERE %(x)s login L', {'x':ueid})
-## self.assertEquals(rset.rows[0][0], 'admin')
+ def test_select_float_abs(self):
+ # test positive number
+ eid = self.execute('INSERT Affaire A: A invoiced %(i)s', {'i': 1.2})[0][0]
+ rset = self.execute('Any ABS(I) WHERE X eid %(x)s, X invoiced I', {'x': eid})
+ self.assertEquals(rset.rows[0][0], 1.2)
+ # test negative number
+ eid = self.execute('INSERT Affaire A: A invoiced %(i)s', {'i': -1.2})[0][0]
+ rset = self.execute('Any ABS(I) WHERE X eid %(x)s, X invoiced I', {'x': eid})
+ self.assertEquals(rset.rows[0][0], 1.2)
+
+ def test_select_int_abs(self):
+ # test positive number
+ eid = self.execute('INSERT Affaire A: A duration %(d)s', {'d': 12})[0][0]
+ rset = self.execute('Any ABS(D) WHERE X eid %(x)s, X duration D', {'x': eid})
+ self.assertEquals(rset.rows[0][0], 12)
+ # test negative number
+ eid = self.execute('INSERT Affaire A: A duration %(d)s', {'d': -12})[0][0]
+ rset = self.execute('Any ABS(D) WHERE X eid %(x)s, X duration D', {'x': eid})
+ self.assertEquals(rset.rows[0][0], 12)
def test_select_searchable_text_1(self):
rset = self.execute(u"INSERT Personne X: X nom 'bidüle'")