Ejemplo n.º 1
0
class CashTransaction(Measurement):
    measurement_name = 'CashTransaction'

    # Fields
    # Date of the transaction
    transactionDate = attributes.TimestampFieldAttribute()
    #The amount of the transaction
    amount = attributes.FloatFieldAttribute()

    #Tags
    # Description of the transaction
    memo = attributes.TagFieldAttribute()
    # Financial Institution specific transaction id
    fi_id = attributes.TagFieldAttribute()
    # Account ID
    account = attributes.TagFieldAttribute()
Ejemplo n.º 2
0
 class MySampleMeasurement(Measurement):
     measurement_name = 'mysamplemeasurement'
     time = attributes.TimestampFieldAttribute(precision="s")
     value = attributes.IntegerFieldAttribute()
Ejemplo n.º 3
0
 class MySampleMeasurement(Measurement):
     measurement_name = 'mysamplemeasurement'
     time = attributes.TimestampFieldAttribute()
     value = attributes.IntegerFieldAttribute(is_nullable=False)
Ejemplo n.º 4
0
 def test_convert_to_precision_success(self):
     attr = attributes.TimestampFieldAttribute()
     attr.set_internal_value(1570209691)
     assert attr.convert_to_precision(1570209691, 'ms') == D('1570209691000')
Ejemplo n.º 5
0
 def test_validate_fail(self):
     with pytest.raises(exceptions.InfluxDBAttributeValueError):
         attributes.TimestampFieldAttribute(precision='k')
Ejemplo n.º 6
0
 def test_convert_to_nanoseconds_success(self):
     attr = attributes.TimestampFieldAttribute()
     attr.set_internal_value(1570209691)
     assert attr.convert_to_nanoseconds(1570209691) == D('1570209691000000000')
Ejemplo n.º 7
0
 def test_clean_with_none_success(self):
     attr = attributes.TimestampFieldAttribute(auto_now=False)
     attr.set_internal_value(None)
     assert attr.get_internal_value() is None
Ejemplo n.º 8
0
 def test_clean_success(self):
     attr = attributes.TimestampFieldAttribute()
     attr.set_internal_value(1570209691)
     assert attr.to_python(1570209691) == D('1570209691000000000')
Ejemplo n.º 9
0
 def test_to_influx_success(self):
     attr = attributes.TimestampFieldAttribute()
     attr.set_internal_value(1570209691)
     assert attr.to_influx(1570209691000000000) == '1570209691000000000'
Ejemplo n.º 10
0
    class PopulateMeasurement(Measurement):
        measurement_name = name

        time = attributes.TimestampFieldAttribute(precision='s')
        phase = attributes.TagFieldAttribute()
        value = attributes.FloatFieldAttribute()