def test_unregister_not_registered(manager: SmartAppManager): """Test register with the same app twice.""" # Act with pytest.raises(ValueError) as e_info: manager.unregister(APP_ID) # Assert assert str(e_info.value) == 'smartapp was not previously registered.'
def test_unregister_no_app_id(manager: SmartAppManager): """Test unregister with no SmartApp app id.""" # Act with pytest.raises(ValueError) as e_info: manager.unregister(None) # Assert assert str(e_info.value) == 'smartapp must have an app_id.'
def test_unregister(manager: SmartAppManager): """Test unregister.""" # Arrange' manager.register(APP_ID, '123') # Act manager.unregister(APP_ID) # Assert assert APP_ID not in manager.smartapps
def test_register_twice(manager: SmartAppManager): """Test register with the same app twice.""" # Arrange public_key = '123' manager.register(APP_ID, public_key) # Act with pytest.raises(ValueError) as e_info: manager.register(APP_ID, public_key) # Assert assert str(e_info.value) == 'smartapp already registered.'
async def test_on_uninstall(manager: SmartAppManager): """Tests the config event handler at the manager level.""" # Arrange request = get_fixture("uninstall_request") app = manager.register(APP_ID, 'none') handler = get_dispatch_handler(app) manager.connect_uninstall(handler) # Act await manager.handle_request(request, None, False) # ensure dispatched tasks complete await asyncio.gather(*manager.dispatcher.last_sent) # Assert assert handler.fired
def test_register(manager: SmartAppManager): """Test register.""" public_key = '123' # Act app = manager.register(APP_ID, public_key) # Assert assert app.app_id == APP_ID assert app.public_key == public_key assert app.path == manager.path assert APP_ID in manager.smartapps
def manager(event_loop) -> SmartAppManager: """Fixture for testing against the SmartAppManager class.""" return SmartAppManager('/path/to/app', dispatcher=Dispatcher(loop=event_loop))