# Path: habitat/sensors/base.py
# def ascii_int(config, data):
# def ascii_float(config, data):
# def string(data):
# def constant(config, data):
# def binary_b64(data):


from nose.tools import assert_raises, raises
from ...sensors import base
        assert base.ascii_int({"base": 16}, "deadbeef") == 3735928559

    @raises(ValueError)
    def test_ascii_ints_with_invalid_strings(self):
        base.ascii_int({}, "NOT AN INT")

    def test_ascii_floats(self):
        assert base.ascii_float({}, "12") == 12.0
        assert base.ascii_float({}, "12.3") == 12.3
        assert base.ascii_float({}, "0.1") == 0.1

    @raises(ValueError)
    def test_ascii_floats_with_invalid_strings(self):
        base.ascii_float({}, "NOT A FLOAT")

    def test_optional(self):
        assert base.ascii_int({"optional": True}, "") == None
        assert base.ascii_float({"optional": True}, "") == None
        assert_raises(ValueError, base.ascii_int, {}, "")
        assert_raises(ValueError, base.ascii_float, {}, "")

    def test_strings(self):
        assert base.string("hello") == "hello"
        assert base.string("123") == "123"

    @raises(ValueError)
    def test_bad_constant(self):
        base.constant({"expect": "right"}, "wrong")

    def test_good_constant(self):

# Path: habitat/sensors/base.py
# def ascii_int(config, data):
# def ascii_float(config, data):
# def string(data):
# def constant(config, data):
# def binary_b64(data):


# Path: habitat/tests/test_sensors/test_base.py
from nose.tools import assert_raises, raises
from ...sensors import base

        assert base.ascii_int({"base": 16}, "deadbeef") == 3735928559

    @raises(ValueError)
    def test_ascii_ints_with_invalid_strings(self):
        base.ascii_int({}, "NOT AN INT")

    def test_ascii_floats(self):
        assert base.ascii_float({}, "12") == 12.0
        assert base.ascii_float({}, "12.3") == 12.3
        assert base.ascii_float({}, "0.1") == 0.1

    @raises(ValueError)
    def test_ascii_floats_with_invalid_strings(self):
        base.ascii_float({}, "NOT A FLOAT")

    def test_optional(self):
        assert base.ascii_int({"optional": True}, "") == None
        assert base.ascii_float({"optional": True}, "") == None
        assert_raises(ValueError, base.ascii_int, {}, "")
        assert_raises(ValueError, base.ascii_float, {}, "")

    def test_strings(self):
        assert base.string("hello") == "hello"
        assert base.string("123") == "123"

    @raises(ValueError)
    def test_bad_constant(self):
        base.constant({"expect": "right"}, "wrong")

    def test_good_constant(self):

        assert base.constant({"expect": "right"}, "right") == None