Exemple #1
0
def test_C3(mpers):
    fullContext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c4, mpers.contexts.c5, mpers.contexts.c6,
        mpers.contexts.c7, mpers.contexts.c8
    ]

    tasks = KnapsackPlanning().isAchievablePlan(mpers.rootGoal, fullContext,
                                                None)

    assert tasks is not None

    for task in tasks.getTasks():
        assert task.identifier != "acceptEmergency"
Exemple #2
0
def test_C10(mpers):
    fullContext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c5, mpers.contexts.c6, mpers.contexts.c8,
        mpers.contexts.c10, mpers.contexts.c12
    ]

    tasks = KnapsackPlanning().isAchievablePlan(mpers.rootGoal, fullContext,
                                                None)

    plan = ["notifyByLightAlert", "acceptEmergency"]
    assert tasks is not None
    for task in tasks.getTasks():
        assert task.identifier not in plan
Exemple #3
0
def test_abidesByInterpretation_not_passing_baseline(mpers):
    isNotifiedAboutEmergencyGoal = mpers.goals.isNotifiedAboutEmergencyGoal
    notifyBySoundAlertTask = mpers.tasks.notifyBySoundAlertTask
    c6 = mpers.contexts.c6
    c1 = mpers.contexts.c1

    context = [c6]
    result = KnapsackPlanning().abidesByInterpretation(
        notifyBySoundAlertTask, isNotifiedAboutEmergencyGoal.interp, context)
    assert result == True

    context = [c1]
    result = KnapsackPlanning().abidesByInterpretation(
        notifyBySoundAlertTask, isNotifiedAboutEmergencyGoal.interp, context)
    assert result == False
Exemple #4
0
def test_C6(mpers):
    fullContext = [
        mpers.contexts.c1, mpers.contexts.c4, mpers.contexts.c5,
        mpers.contexts.c6, mpers.contexts.c7, mpers.contexts.c8,
        mpers.contexts.c10, mpers.contexts.c12
    ]

    tasks = KnapsackPlanning().isAchievablePlan(mpers.rootGoal, fullContext,
                                                None)

    plan = ["notifyCentralBySMS", "confirmEmergencyByCall", "sendInfoBySMS"]

    assert tasks is not None

    for task in tasks.getTasks():
        assert task.identifier not in plan
Exemple #5
0
def test_abidesByInterpretation_passing_baseline(mpers):
    isNotifiedAboutEmergencyGoal = mpers.goals.isNotifiedAboutEmergencyGoal
    notifyByMobileVibrationTask = mpers.tasks.notifyByMobileVibrationTask
    c1 = mpers.contexts.c1
    c9 = mpers.contexts.c9

    context = [c1]
    result = KnapsackPlanning().abidesByInterpretation(
        notifyByMobileVibrationTask, isNotifiedAboutEmergencyGoal.interp,
        context)
    assert result == True

    context = [c9]
    result = KnapsackPlanning().abidesByInterpretation(
        notifyByMobileVibrationTask, isNotifiedAboutEmergencyGoal.interp,
        context)
    assert result == True
Exemple #6
0
def test_abidesByInterpretation_context_not_passing(mpers):
    identifyLocationByVoiceCallTask = mpers.tasks.identifyLocationByVoiceCallTask
    locationIsIdentifiedGoal = mpers.goals.locationIsIdentifiedGoal
    c5 = mpers.contexts.c5

    context = []

    result = KnapsackPlanning().abidesByInterpretation(
        identifyLocationByVoiceCallTask, locationIsIdentifiedGoal.interp,
        context)
    assert result == True

    context.append(c5)

    result = KnapsackPlanning().abidesByInterpretation(
        identifyLocationByVoiceCallTask, locationIsIdentifiedGoal.interp,
        context)
    assert result == False
Exemple #7
0
def test_abidesByInterpretation_only_baseline(mpers):
    considerLastKnownLocationTask = mpers.tasks.considerLastKnownLocationTask
    locationIsIdentifiedGoal = mpers.goals.locationIsIdentifiedGoal
    context = []

    result = KnapsackPlanning().abidesByInterpretation(
        considerLastKnownLocationTask, locationIsIdentifiedGoal.interp,
        context)
    assert result == True
Exemple #8
0
def test_abidesByInterpretation_only_baseline_not_passing(mpers):
    locationIsIdentifiedGoal = mpers.goals.locationIsIdentifiedGoal
    context = []

    LongSecondsTask = KnapsackObject("LongSecondsTask")
    LongSecondsTask.setProvidedQuality(None, MpersMetrics.SECONDS, 1500)

    result = KnapsackPlanning().abidesByInterpretation(
        LongSecondsTask, locationIsIdentifiedGoal.interp, context)
    assert result == False
Exemple #9
0
def test_C4(mpers):
    fullContext = [
        mpers.contexts.c1, mpers.contexts.c4, mpers.contexts.c6,
        mpers.contexts.c7, mpers.contexts.c8, mpers.contexts.c10,
        mpers.contexts.c12
    ]

    tasks = KnapsackPlanning().isAchievablePlan(mpers.rootGoal, fullContext,
                                                None)

    plan = [
        "notifyCentralBySMS", "confirmEmergencyByCall", "notifyBySoundAlert",
        "sendInfoBySMS", "identifyLocationByVoiceCall",
        "accessLocationFromTriangulation"
    ]
    assert tasks is not None

    for task in tasks.getTasks():
        assert task.identifier not in plan
Exemple #10
0
def test_EmergencyIsDetectedGoal(mpers):
    fullcontext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c4, mpers.contexts.c8
    ]
    plan = KnapsackPlanning().isAchievablePlan(
        mpers.goals.emergencyIsDetectedGoal, fullcontext, None)

    assert assertPlan(plan, [
        mpers.tasks.notifyCentralByInternetTask,
        mpers.tasks.confirmEmergencyByCallTask
    ])
Exemple #11
0
def test_IsNotifiedAboutEmergencyGoal(mpers):
    fullcontext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c4, mpers.contexts.c5, mpers.contexts.c6,
        mpers.contexts.c7, mpers.contexts.c8, mpers.contexts.c9,
        mpers.contexts.c10
    ]

    plan = KnapsackPlanning().isAchievablePlan(
        mpers.goals.isNotifiedAboutEmergencyGoal, fullcontext, None)

    assert assertPlan(plan, [mpers.tasks.notifyByLightAlertTask])
Exemple #12
0
def test_infoIsPreparedGoal(mpers):
    fullcontext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c4, mpers.contexts.c8
    ]

    plan = KnapsackPlanning().isAchievablePlan(mpers.goals.infoIsPreparedGoal,
                                               fullcontext, None)

    assert assertPlan(plan, [
        mpers.tasks.accessLocationFromGPSTask,
        mpers.tasks.accessDataFromDatabaseTask
    ])
Exemple #13
0
def test_centralReceivesInfoGoal(mpers):
    fullcontext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c4, mpers.contexts.c8
    ]

    plan = KnapsackPlanning().isAchievablePlan(
        mpers.goals.centralReceivesInfoGoal, fullcontext, None)

    assert assertPlan(plan, [
        mpers.tasks.sendInfoByInternetTask,
        mpers.tasks.accessLocationFromGPSTask,
        mpers.tasks.accessDataFromDatabaseTask
    ])
Exemple #14
0
def test_C1(mpers):
    fullContext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c4,
        mpers.contexts.c5, mpers.contexts.c7, mpers.contexts.c8,
        mpers.contexts.c10, mpers.contexts.c12
    ]
    plan = KnapsackPlanning().isAchievablePlan(mpers.rootGoal, fullContext,
                                               None)

    assert plan is not None

    assert False is assertPlan(
        plan,
        [mpers.tasks.accessLocationFromGPSTask, mpers.tasks.centralCallTask])
Exemple #15
0
def test_MPERS_model(mpers):
    fullcontext = [
        mpers.contexts.c1, mpers.contexts.c2, mpers.contexts.c3,
        mpers.contexts.c4, mpers.contexts.c8
    ]
    plan = KnapsackPlanning().isAchievablePlan(mpers.rootGoal, fullcontext,
                                               None)

    assert True is assertPlan(plan, [
        mpers.tasks.notifyCentralByInternetTask,
        mpers.tasks.confirmEmergencyByCallTask,
        mpers.tasks.notifyByMobileVibrationTask,
        mpers.tasks.sendInfoByInternetTask,
        mpers.tasks.accessLocationFromGPSTask,
        mpers.tasks.accessDataFromDatabaseTask,
        mpers.tasks.ambulanceDispatchDelegationTask,
    ])
Exemple #16
0
    def isAchievable(self, current, interp):
        newInterp = Interpretation()
        newInterp.merge(self.interp)
        newInterp.merge(interp)

        return KnapsackPlanning().isAchievable(self, current, newInterp)