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
 def test_validate_invalid_type_fail(self):
     with pytest.raises(exceptions.InfluxDBAttributeValueError):
         attributes.FloatFieldAttribute(max_nb_decimals='ok')
Ejemplo n.º 3
0
 def test_validate_negative_max_nb_decimals_fail(self):
     with pytest.raises(exceptions.InfluxDBAttributeValueError):
         attributes.FloatFieldAttribute(max_nb_decimals=-5)
Ejemplo n.º 4
0
 def test_to_influx_success(self):
     attr = attributes.FloatFieldAttribute()
     assert attr.to_influx(5.2504) == '5.2504'
Ejemplo n.º 5
0
 def test_to_python_success(self):
     attr = attributes.FloatFieldAttribute()
     assert attr.to_python(5.2504) == 5.2504
Ejemplo n.º 6
0
 def test_clean_with_max_nb_decimals_success(self):
     attr = attributes.FloatFieldAttribute(max_nb_decimals=2)
     attr.clean(5.2345)
     assert attr.get_internal_value() == D(5.23).quantize(D('.01'))
Ejemplo n.º 7
0
 def test_clean_success(self):
     attr = attributes.FloatFieldAttribute()
     attr.set_internal_value(5.2345)
     assert attr.get_internal_value() == D(5.2345)
Ejemplo n.º 8
0
    class PopulateMeasurement(Measurement):
        measurement_name = name

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