Exemplo n.º 1
0
 def test_owned_by_user(self):
     user = CommCareUser.create(self.domain, 'owned-user-test', 'password')
     user.save()
     owners = get_owning_users(user._id)
     self.assertEqual(1, len(owners))
     self.assertEqual(owners[0]._id, user._id)
     self.assertTrue(isinstance(owners[0], CommCareUser))
Exemplo n.º 2
0
 def test_owned_by_user(self):
     user = CommCareUser.create(self.domain, 'owned-user-test', 'password')
     user.save()
     owners = get_owning_users(user._id)
     self.assertEqual(1, len(owners))
     self.assertEqual(owners[0]._id, user._id)
     self.assertTrue(isinstance(owners[0], CommCareUser))
Exemplo n.º 3
0
def get_notification_recipients(next_action, requisition):
    # given a status and list of requisitions, get the exhaustive list of
    # people to notify about the requisition entering that status.
    users = get_owning_users(get_owner_id(requisition))
    if len(users) == 1:
        return users
    return [u for u in users if should_notify_user(u, next_action.action_type)]
Exemplo n.º 4
0
def get_notification_recipients(next_action, requisition):
    # given a status and list of requisitions, get the exhaustive list of
    # people to notify about the requisition entering that status.
    users = get_owning_users(get_owner_id(requisition))
    if len(users) == 1:
        return users
    return [u for u in users if should_notify_user(u, next_action.action_type)]
Exemplo n.º 5
0
    def test_owned_by_group(self):
        ids = []
        for i in range(5):
            user = CommCareUser.create(self.domain, 'owned-group-test-user-%s' % i, 'password')
            user.save()
            ids.append(user._id)

        group = Group(domain=self.domain, name='owned-group-test-group', users=ids)
        group.save()
        owners = get_owning_users(group._id)
        self.assertEqual(5, len(owners))
        ids_back = []
        for o in owners:
            self.assertTrue(isinstance(o, CommCareUser))
            ids_back.append(o._id)
        self.assertEqual(set(ids), set(ids_back))
Exemplo n.º 6
0
    def test_owned_by_group(self):
        ids = []
        for i in range(5):
            user = CommCareUser.create(self.domain, 'owned-group-test-user-%s' % i, 'password', None, None)
            user.save()
            self.addCleanup(user.delete, deleted_by=None)
            ids.append(user._id)

        group = Group(domain=self.domain, name='owned-group-test-group', users=ids)
        group.save()
        self.addCleanup(group.delete)
        owners = get_owning_users(group._id)
        self.assertEqual(5, len(owners))
        ids_back = []
        for o in owners:
            self.assertTrue(isinstance(o, CommCareUser))
            ids_back.append(o._id)
        self.assertEqual(set(ids), set(ids_back))