def testGroupFilters(self): domain = 'case-export-test' active_user = CommCareUser.create(domain=domain, username='******', password='******') inactive_user = CommCareUser.create(domain=domain, username='******', password='******') inactive_user.is_active = False inactive_user.save() group = Group(domain=domain, name='group', users=[active_user._id, inactive_user._id]) group.save() # no matter what the group should match on ownerid (but not user id) self.assertTrue(case_group_filter(_mock_case(group._id, 'nobody'), group)) self.assertTrue(case_group_filter(_mock_case(group._id, active_user._id), group)) self.assertTrue(case_group_filter(_mock_case(group._id, inactive_user._id), group)) self.assertFalse(case_group_filter(_mock_case('nobody', group._id), group)) # test active users count self.assertTrue(case_group_filter(_mock_case(active_user._id, 'nobody'), group)) self.assertTrue(case_group_filter(_mock_case('nobody', active_user._id), group)) self.assertTrue(case_group_filter(_mock_case(active_user._id, active_user._id), group)) # test inactive users don't count self.assertFalse(case_group_filter(_mock_case(inactive_user._id, 'nobody'), group)) self.assertFalse(case_group_filter(_mock_case('nobody', inactive_user._id), group)) self.assertFalse(case_group_filter(_mock_case(inactive_user._id, inactive_user._id), group)) # combinations of active and inactive should count self.assertTrue(case_group_filter(_mock_case(active_user._id, inactive_user._id), group)) self.assertTrue(case_group_filter(_mock_case(inactive_user._id, active_user._id), group)) # duh self.assertFalse(case_group_filter(_mock_case('nobody', 'nobody-else'), group))
def testGroupFilters(self): domain = 'case-export-test' active_user = CommCareUser.create(domain=domain, username='******', password='******', created_by=None, created_via=None) inactive_user = CommCareUser.create(domain=domain, username='******', password='******', created_by=None, created_via=None) inactive_user.is_active = False inactive_user.save() group = Group(domain=domain, name='group', users=[active_user._id, inactive_user._id]) group.save() # no matter what the group should match on ownerid (but not user id) self.assertTrue( case_group_filter(_mock_case(group._id, 'nobody'), group)) self.assertTrue( case_group_filter(_mock_case(group._id, active_user._id), group)) self.assertTrue( case_group_filter(_mock_case(group._id, inactive_user._id), group)) self.assertFalse( case_group_filter(_mock_case('nobody', group._id), group)) # test active users count self.assertTrue( case_group_filter(_mock_case(active_user._id, 'nobody'), group)) self.assertTrue( case_group_filter(_mock_case('nobody', active_user._id), group)) self.assertTrue( case_group_filter(_mock_case(active_user._id, active_user._id), group)) # test inactive users don't count self.assertFalse( case_group_filter(_mock_case(inactive_user._id, 'nobody'), group)) self.assertFalse( case_group_filter(_mock_case('nobody', inactive_user._id), group)) self.assertFalse( case_group_filter(_mock_case(inactive_user._id, inactive_user._id), group)) # combinations of active and inactive should count self.assertTrue( case_group_filter(_mock_case(active_user._id, inactive_user._id), group)) self.assertTrue( case_group_filter(_mock_case(inactive_user._id, active_user._id), group)) # duh self.assertFalse( case_group_filter(_mock_case('nobody', 'nobody-else'), group))
def testGroupFilters(self): domain = "case-export-test" active_user = CommCareUser.create(domain=domain, username="******", password="******") inactive_user = CommCareUser.create(domain=domain, username="******", password="******") inactive_user.is_active = False inactive_user.save() group = Group(domain=domain, name="group", users=[active_user._id, inactive_user._id]) group.save() # no matter what the group should match on ownerid (but not user id) self.assertTrue(case_group_filter(_mock_case(group._id, "nobody"), group)) self.assertTrue(case_group_filter(_mock_case(group._id, active_user._id), group)) self.assertTrue(case_group_filter(_mock_case(group._id, inactive_user._id), group)) self.assertFalse(case_group_filter(_mock_case("nobody", group._id), group)) # test active users count self.assertTrue(case_group_filter(_mock_case(active_user._id, "nobody"), group)) self.assertTrue(case_group_filter(_mock_case("nobody", active_user._id), group)) self.assertTrue(case_group_filter(_mock_case(active_user._id, active_user._id), group)) # test inactive users don't count self.assertFalse(case_group_filter(_mock_case(inactive_user._id, "nobody"), group)) self.assertFalse(case_group_filter(_mock_case("nobody", inactive_user._id), group)) self.assertFalse(case_group_filter(_mock_case(inactive_user._id, inactive_user._id), group)) # combinations of active and inactive should count self.assertTrue(case_group_filter(_mock_case(active_user._id, inactive_user._id), group)) self.assertTrue(case_group_filter(_mock_case(inactive_user._id, active_user._id), group)) # duh self.assertFalse(case_group_filter(_mock_case("nobody", "nobody-else"), group))