コード例 #1
0
 def setUp(self):
     """
     WardStrategy needs patient placements.
     """
     bed_patient = PatientsGenerator(0, 2, 0, 'a')
     self.gen = PlacementsGenerator(bed_patient, [-1, -2])
     self.patients = patients_factory(self.gen.root)
     risk = {'high': 1, 'medium': 2, 'low': 10, 'none': 15}
     self.user_ids = ['user_1', 'user_2']
     self.strategy = WardStrategy(self.patients, self.user_ids, risk, 1, 1,
                                  [30])
コード例 #2
0
class TestWardStrategy(unittest.TestCase):
    """
    Test that WardStrategy creates strategy.
    """

    def setUp(self):
        """
        WardStrategy needs patient placements.
        """
        bed_patient = PatientsGenerator(0, 2, 0, 'a')
        self.gen = PlacementsGenerator(bed_patient, [-1, -2])
        self.patients = patients_factory(self.gen.root)
        risk = {'high': 1, 'medium': 2, 'low': 10, 'none': 15}
        self.user_ids = ['user_1', 'user_2']
        self.strategy = WardStrategy(self.patients, self.user_ids, risk, 1, 1,
                                     [30])

    def test_pick_user_id(self):
        user_id = self.strategy.pick_user_id()

        self.assertTrue(user_id in self.user_ids)

    def test_get_hca_nurse_users(self):
        basic_schema = {
            'hca': {'total': 1, 'per_ward': 1, 'unassigned': 0},
            'nurse': {'total': 1, 'per_ward': 1, 'unassigned': 0}
        }
        gen = UsersGenerator(basic_schema)
        doc = gen.generate_users_per_ward('a', 2)

        user_ids = get_hca_nurse_users(doc)

        self.assertEqual(len(user_ids), 2)

    def test_get_role(self):
        hca = "[(4, ref('nh_clinical.role_nhc_hca'))]"
        basic_schema = {'hca': {'total': 1, 'per_ward': 1, 'unassigned': 0}}
        gen = UsersGenerator(basic_schema)
        doc = gen.generate_users_per_ward('a', 2)
        user = doc.findall(".//record/[@model='res.users']")[0]

        role = get_role(user)

        self.assertEqual(role, hca)