def test_raises_on_incorrect_input_type(self): """ Assert that `to_uuid` raises error on wrong input class """ with pytest.raises(TypeError) as exc: to_uuid(3.0) assert "Cannot convert object to UUID" in str(exc) assert "float" in str(exc)
def stream_from_uuid(self, uuid): """ Creates a stream handle to the BTrDB stream with the UUID `uuid`. This method does not check whether a stream with the specified UUID exists. It is always good form to check whether the stream existed using `stream.exists()`. Parameters ---------- uuid: UUID The uuid of the requested stream. Returns ------- Stream instance of Stream class or None """ return Stream(self, to_uuid(uuid))
def test_raises_on_bad_data(self): """ Assert that `to_uuid` raises error with bad UUID string """ with pytest.raises(ValueError): to_uuid("bad data!!!")
def test_from_uuid(self): """ Assert that `to_uuid` returns passed UUID """ assert to_uuid(EXAMPLE_UUID) == EXAMPLE_UUID
def test_from_str(self): """ Assert that `to_uuid` converts from str """ assert to_uuid(EXAMPLE_UUID_STR) == EXAMPLE_UUID
def test_from_bytes(self): """ Assert that `to_uuid` converts from bytes """ assert to_uuid(EXAMPLE_UUID_BYTES) == EXAMPLE_UUID