Merge "empty non-string values are returned as string traits"
This commit is contained in:
commit
b89972d74f
@ -320,13 +320,13 @@ class Connection(base.Connection):
|
|||||||
|
|
||||||
for id_, key, t_date, t_int, t_float, t_text in (
|
for id_, key, t_date, t_int, t_float, t_text in (
|
||||||
trait_q.order_by('2')).all():
|
trait_q.order_by('2')).all():
|
||||||
if t_int:
|
if t_int is not None:
|
||||||
dtype = api_models.Trait.INT_TYPE
|
dtype = api_models.Trait.INT_TYPE
|
||||||
val = t_int
|
val = t_int
|
||||||
elif t_float:
|
elif t_float is not None:
|
||||||
dtype = api_models.Trait.FLOAT_TYPE
|
dtype = api_models.Trait.FLOAT_TYPE
|
||||||
val = t_float
|
val = t_float
|
||||||
elif t_date:
|
elif t_date is not None:
|
||||||
dtype = api_models.Trait.DATETIME_TYPE
|
dtype = api_models.Trait.DATETIME_TYPE
|
||||||
val = t_date
|
val = t_date
|
||||||
else:
|
else:
|
||||||
|
@ -3668,6 +3668,22 @@ class GetEventTest(EventTestBase):
|
|||||||
self.assertTrue(events)
|
self.assertTrue(events)
|
||||||
self.assertEqual({'status': {'nested': 'started'}}, events[0].raw)
|
self.assertEqual({'status': {'nested': 'started'}}, events[0].raw)
|
||||||
|
|
||||||
|
def test_trait_type_enforced_on_none(self):
|
||||||
|
new_events = [event_models.Event(
|
||||||
|
"id_testid", "MessageIDTest", self.start,
|
||||||
|
[event_models.Trait('text', event_models.Trait.TEXT_TYPE, ''),
|
||||||
|
event_models.Trait('int', event_models.Trait.INT_TYPE, 0),
|
||||||
|
event_models.Trait('float', event_models.Trait.FLOAT_TYPE, 0.0)],
|
||||||
|
{})]
|
||||||
|
self.event_conn.record_events(new_events)
|
||||||
|
event_filter = storage.EventFilter(message_id="id_testid")
|
||||||
|
events = [event for event in self.event_conn.get_events(event_filter)]
|
||||||
|
options = [(event_models.Trait.TEXT_TYPE, ''),
|
||||||
|
(event_models.Trait.INT_TYPE, 0.0),
|
||||||
|
(event_models.Trait.FLOAT_TYPE, 0.0)]
|
||||||
|
for trait in events[0].traits:
|
||||||
|
options.remove((trait.dtype, trait.value))
|
||||||
|
|
||||||
|
|
||||||
class BigIntegerTest(tests_db.TestBase,
|
class BigIntegerTest(tests_db.TestBase,
|
||||||
tests_db.MixinTestsWithBackendScenarios):
|
tests_db.MixinTestsWithBackendScenarios):
|
||||||
|
Loading…
Reference in New Issue
Block a user