def test_delete_sp_with_stations(setup_db, actor_setup): session = setup_db on_si_changed_call_history = [] on_pi_changed_call_history = [] on_si_changed_verification = [('DELETE', {"id": 2, "codops": "rai"}, None)] on_pi_changed_verification = [ ('DELETE', 1), ('DELETE', 3), ] create_handler( lambda event_name, service_provider, client: on_si_changed_call_history .append((event_name, service_provider, client)), lambda event_name, station: on_pi_changed_call_history.append( (event_name, station)), ) delete_sp(session, 2) assert len(on_si_changed_call_history) == len(on_si_changed_verification) assert len(on_pi_changed_call_history) == len(on_pi_changed_verification) for call in on_si_changed_call_history: assert call in on_si_changed_verification for call in on_pi_changed_call_history: assert call in on_pi_changed_verification session.close()
def test_delete_sp_with_stations(setup_db, actor_setup): session = setup_db on_si_changed_call_history = [] on_pi_changed_call_history = [] on_si_changed_verification = [('DELETE', {"id": 2, "codops": "rai"}, None)] on_pi_changed_verification = [ ('DELETE', 1), ('DELETE', 3), ] create_handler( lambda event_name, service_provider, client: on_si_changed_call_history.append( (event_name, service_provider, client)), lambda event_name, station: on_pi_changed_call_history.append((event_name, station)), ) delete_sp(session, 2) assert len(on_si_changed_call_history) == len(on_si_changed_verification) assert len(on_pi_changed_call_history) == len(on_pi_changed_verification) for call in on_si_changed_call_history: assert call in on_si_changed_verification for call in on_pi_changed_call_history: assert call in on_pi_changed_verification session.close()
def test_update_ecc(setup_db, actor_setup): session = setup_db on_si_changed_call_history = [] on_pi_changed_call_history = [] client = Clients.query.filter_by(id=1).first() sp3 = ServiceProvider.query.filter_by(id=3).first() sp2 = ServiceProvider.query.filter_by(id=2).first() on_si_changed_verification = [('UPDATE', sp3, None), ('UPDATE', sp2, client), ('UPDATE', sp2, None)] on_pi_changed_verification = [ ('UPDATE', Station.query.filter_by(id=1).first()), ('UPDATE', Station.query.filter_by(id=3).first()), ] create_handler( lambda event_name, service_provider, client: on_si_changed_call_history.append( (event_name, service_provider, client)), lambda event_name, station: on_pi_changed_call_history.append((event_name, station)), ) update_ecc(session, 1) assert len(on_si_changed_call_history) == len(on_si_changed_verification) assert len(on_pi_changed_call_history) == len(on_pi_changed_verification) for call in on_si_changed_call_history: assert call in on_si_changed_verification for call in on_pi_changed_call_history: assert call in on_pi_changed_verification session.close()
def test_reload_command(setup_db, actor_setup): session = setup_db on_si_changed_call_history = [] on_pi_changed_call_history = [] sp = ServiceProvider.query.filter_by(id=2).first() client = Clients.query.filter_by(id=1).first() on_si_changed_verification = [('UPDATE', sp, None), ('UPDATE', sp, client)] on_pi_changed_verification = [ ('UPDATE', Station.query.filter_by(id=1).first()), ('UPDATE', Station.query.filter_by(id=3).first()), ] create_handler( lambda event_name, service_provider, client: on_si_changed_call_history.append( (event_name, service_provider, client)), lambda event_name, station: on_pi_changed_call_history.append((event_name, station)), ) actor_setup.tell_to_actor({"type": "add", "subject": "reload", "id": sp.id, "action": "update"}) time.sleep(config.SPI_GENERATION_INTERVAL * 3) assert len(on_si_changed_call_history) == len(on_si_changed_verification) assert len(on_pi_changed_call_history) == len(on_pi_changed_verification) for call in on_si_changed_call_history: assert call in on_si_changed_verification for call in on_pi_changed_call_history: assert call in on_pi_changed_verification session.close()
def test_picture_delete(setup_db, actor_setup): session = setup_db on_si_changed_call_history = [] create_picture(session, -1, "mysuperbepicture") client = Clients.query.filter_by(id=1).first() sp = ServiceProvider.query.filter_by(id=2).first() on_si_changed_verification = [('UPDATE', sp, client), ('UPDATE', sp, None)] create_handler( lambda event_name, service_provider, client: on_si_changed_call_history.append( (event_name, service_provider, client)), lambda event_name, station_id: None, ) delete_picture(session, 2) assert len(on_si_changed_call_history) == len(on_si_changed_verification) for call in on_si_changed_call_history: assert call in on_si_changed_verification session.close()
def test_logo_image_update(setup_db, actor_setup): session = setup_db on_si_changed_call_history = [] client = Clients.query.filter_by(id=1).first() sp = ServiceProvider.query.filter_by(id=2).first() on_si_changed_verification = sorted([('UPDATE', sp, client), ('UPDATE', sp, None)]) create_handler( lambda event_name, service_provider, client: on_si_changed_call_history .append((event_name, service_provider, client)), lambda event_name, station_id: None, ) update_logo_image(session, 1) assert len(on_si_changed_call_history) == len(on_si_changed_verification) for call in on_si_changed_call_history: assert call in on_si_changed_verification session.close()
def create_mocks_manually(): on_si_changed = mock.Mock() on_pi_changed = mock.Mock() create_handler(on_si_changed, on_pi_changed) return on_si_changed, on_pi_changed