def test_render(app):
    with app.app_context():
        message = WarehouseMessage("mytype", "myuuid", "at some point")
        with pytest.raises(Exception):
            message.render()

        message.set_user_id("my user")

        assert isinstance(message.render(), Message)
def test_construct_event_message(app):
    with app.app_context():
        message = WarehouseMessage("mytype", "myuuid", "at some point")

        with pytest.raises(Exception):
            message.construct_event_message("myuuid", "some date", [{"data": "data2"}], {"test": "test2"})

        message.set_user_id("my user")
        msg = message.construct_event_message("myuuid", "some date", [{"data": "data2"}], {"test": "test2"})

        assert msg == {
            "event": {
                "uuid": "myuuid",
                "event_type": "mytype",
                "occured_at": "some date",
                "user_identifier": "my user",
                "subjects": [{"data": "data2"}],
                "metadata": {"test": "test2"},
            },
            "lims": app.config["RMQ_LIMS_ID"],
        }
def test_can_set_user_id():
    message = WarehouseMessage("mytype", "myuuid", "at some point")
    message.set_user_id("user 1")

    assert message._user_id == "user 1"
Beispiel #4
0
 def add_to_warehouse_message(self, message: WarehouseMessage):
     message.set_user_id(self.value)