Пример #1
0
def test_move_organ():
    test_organ = Organ(organ_type=OrganType.Heart,
                       blood_type=o_neg,
                       location=1)

    # tests initial values
    assert test_organ.current_location is 1
    assert test_organ.origin_location is 1
    assert test_organ.viability is 60
    assert test_organ.path == [test_organ.origin_location]

    # tests altered values are as expected
    test_organ.move_organ(2, 20, ([1, 2, 3], 200))
    assert test_organ.current_location is 2
    assert test_organ.origin_location is 1
    assert test_organ.viability is 40
    assert test_organ.path == [1, 2, 3]

    # tests whether moving cost can be greater than current viability
    test_organ.move_organ(3, 100, ([3, 2, 1], 500))
    assert test_organ.current_location is 2
    assert test_organ.origin_location is 1
    assert test_organ.viability is 40
    assert test_organ.path == [1, 2, 3]
Пример #2
0
                    organ_needed=OrganType.Lungs,
                    blood_type=BloodType(BloodTypeLetter.AB,
                                         BloodTypePolarity.POS),
                    priority=4,
                    location=hospital_g.node_id)
patient_e = Patient(patient_name='patient e',
                    illness='diabetes',
                    organ_needed=OrganType.Pancreas,
                    blood_type=BloodType(BloodTypeLetter.AB,
                                         BloodTypePolarity.POS),
                    priority=100,
                    location=hospital_b.node_id)

# harvests a handful of organs (single donor, same source location)
harvest_organ_1 = Organ(organ_type=OrganType.Pancreas,
                        blood_type=BloodType(BloodTypeLetter.A,
                                             BloodTypePolarity.NEG),
                        location=hospital_a.node_id)
harvest_organ_2 = Organ(organ_type=OrganType.Heart,
                        blood_type=BloodType(BloodTypeLetter.A,
                                             BloodTypePolarity.NEG),
                        location=hospital_a.node_id)
harvest_organ_3 = Organ(organ_type=OrganType.Liver,
                        blood_type=BloodType(BloodTypeLetter.A,
                                             BloodTypePolarity.NEG),
                        location=hospital_a.node_id)
harvest_organ_4 = Organ(organ_type=OrganType.Lungs,
                        blood_type=BloodType(BloodTypeLetter.A,
                                             BloodTypePolarity.NEG),
                        location=hospital_a.node_id)

# constructs dijkstra instance (only need 1 as all organs share the same source)