Exemplo n.º 1
0
def test_flag_triggered_appointments(db_manager):
    for _ in range(ITERATIONS):
        appointments, locator_uuid_map = set_up_appointments(
            db_manager, MAX_ITEMS)
        triggered_appointments = random.sample(list(appointments.keys()),
                                               k=ITEMS)

        len_before_clean = len(appointments)
        Cleaner.flag_triggered_appointments(triggered_appointments,
                                            appointments, locator_uuid_map,
                                            db_manager)

        # ITEMS appointments should have been deleted from memory
        assert len(appointments) == len_before_clean - ITEMS

        # Make sure that all appointments are flagged as triggered in the db
        db_appointments = db_manager.load_all_triggered_flags()
        assert set(triggered_appointments).issubset(db_appointments)
Exemplo n.º 2
0
def test_flag_triggered_appointments(db_manager):
    # Test that when an appointment is flagged and triggered it is deleted from memory and the flags are added to the db
    for _ in range(ITERATIONS):
        appointments, locator_uuid_map = set_up_appointments(
            db_manager, MAX_ITEMS)
        triggered_appointments = random.sample(list(appointments.keys()),
                                               k=ITEMS)

        # Flag the appointments
        Cleaner.flag_triggered_appointments(triggered_appointments,
                                            appointments, locator_uuid_map,
                                            db_manager)

        # Check that the flagged appointments are not in memory anymore
        assert not set(triggered_appointments).issubset(appointments)

        # Make sure that all appointments are flagged as triggered in the db
        db_appointments = db_manager.load_all_triggered_flags()
        assert set(triggered_appointments).issubset(db_appointments)