def setUpClass(cls): db = SimplifiedSyncLog.get_db() # datetime.min is not compatible for `json_format_datetime` for synclog_id in get_synclog_ids_by_date(datetime(1970, 1, 1), datetime.max): db.delete_doc(synclog_id) # Needed because other tests do not always clean up their users. delete_all_users() hard_delete_deleted_users() cls.g1 = Group(domain=cls.domain, name='group') cls.g1.save() cls.g2 = Group(domain=cls.domain, name='group') cls.g2.soft_delete() cls.domain_obj = Domain( name=cls.domain, is_active=True, ) cls.domain_obj.save() cls.web_user = WebUser.create(cls.domain, 'web-user', '***') cls.commcare_user = CommCareUser.create(cls.domain, 'cc-user', '***') cls.commcare_user.retire() cls.synclog = SimplifiedSyncLog( domain=cls.domain, build_id='1234', user_id='5678', date=datetime.utcnow(), ) cls.synclog.save()
def setUpClass(cls): super(AllCommCareUsersTest, cls).setUpClass() delete_all_users() hard_delete_deleted_users() cls.ccdomain = Domain(name='cc_user_domain') cls.ccdomain.save() cls.other_domain = Domain(name='other_domain') cls.other_domain.save() UserRole.init_domain_with_presets(cls.ccdomain.name) cls.user_roles = UserRole.by_domain(cls.ccdomain.name) cls.custom_role = UserRole.get_or_create_with_permissions( cls.ccdomain.name, Permissions( edit_apps=True, edit_web_users=True, view_web_users=True, view_roles=True, ), "Custom Role" ) cls.custom_role.save() cls.ccuser_1 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_2 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_2.set_role(cls.ccdomain.name, cls.custom_role.get_qualified_id()) cls.ccuser_2.save() cls.web_user = WebUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_other_domain = CommCareUser.create( domain=cls.other_domain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user.retire()
def setUpClass(cls): super(AllCommCareUsersTest, cls).setUpClass() delete_all_users() hard_delete_deleted_users() cls.ccdomain = Domain(name='cc_user_domain') cls.ccdomain.save() cls.other_domain = Domain(name='other_domain') cls.other_domain.save() UserRole.init_domain_with_presets(cls.ccdomain.name) cls.user_roles = UserRole.by_domain(cls.ccdomain.name) cls.custom_role = UserRole.get_or_create_with_permissions( cls.ccdomain.name, Permissions( edit_apps=True, edit_web_users=True, view_web_users=True, view_roles=True, ), "Custom Role") cls.custom_role.save() cls.ccuser_1 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_2 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_2.set_role(cls.ccdomain.name, cls.custom_role.get_qualified_id()) cls.ccuser_2.save() cls.web_user = WebUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_other_domain = CommCareUser.create( domain=cls.other_domain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user.retire()
def setUpClass(cls): super(TestDbAccessors, cls).setUpClass() delete_all_sync_logs() # Needed because other tests do not always clean up their users or applications. delete_all_users() hard_delete_deleted_users() delete_all_apps() cls.g1 = Group(domain=cls.domain, name='group') cls.g1.save() cls.g2 = Group(domain=cls.domain, name='group') cls.g2.soft_delete() cls.domain_obj = Domain( name=cls.domain, is_active=True, ) cls.domain_obj.save() cls.web_user = WebUser.create(cls.domain, 'web-user', '***') cls.commcare_user = CommCareUser.create(cls.domain, 'cc-user', '***') cls.commcare_user.retire() cls.synclog = SimplifiedSyncLog( domain=cls.domain, build_id='1234', user_id='5678', date=datetime.utcnow(), ) cls.synclog.save() cls.test_app = Application(domain=cls.domain, name='test-app') cls.test_app.save() cls.deleted_app = Application(domain=cls.domain, name='deleted-app', doc_type='Application-Deleted') cls.deleted_app.save() cls.linked_app = LinkedApplication(domain=cls.domain, name='linked-app', doc_type='Application-Deleted') cls.linked_app.save()
def setUpClass(cls): super(AllCommCareUsersTest, cls).setUpClass() delete_all_users() hard_delete_deleted_users() cls.ccdomain = Domain(name='cc_user_domain') cls.ccdomain.save() cls.other_domain = Domain(name='other_domain') cls.other_domain.save() cls.ccuser_1 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_2 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.web_user = WebUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_other_domain = CommCareUser.create( domain=cls.other_domain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user.retire()
def setUpClass(cls): super(AllCommCareUsersTest, cls).setUpClass() delete_all_users() hard_delete_deleted_users() cls.ccdomain = Domain(name='cc_user_domain') cls.ccdomain.save() cls.other_domain = Domain(name='other_domain') cls.other_domain.save() cls.ccuser_1 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_2 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.web_user = WebUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.ccuser_other_domain = CommCareUser.create( domain=cls.other_domain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', email='*****@*****.**', ) cls.retired_user.retire()
def setUpClass(cls): super(AllCommCareUsersTest, cls).setUpClass() delete_all_users() hard_delete_deleted_users() cls.ccdomain = Domain(name='cc_user_domain') cls.ccdomain.save() cls.other_domain = Domain(name='other_domain') cls.other_domain.save() bootstrap_location_types(cls.ccdomain.name) UserRole.init_domain_with_presets(cls.ccdomain.name) cls.user_roles = UserRole.by_domain(cls.ccdomain.name) cls.custom_role = UserRole.get_or_create_with_permissions( cls.ccdomain.name, Permissions( edit_apps=True, edit_web_users=True, view_web_users=True, view_roles=True, ), "Custom Role") cls.custom_role.save() cls.loc1 = make_loc('spain', domain=cls.ccdomain.name, type="district") cls.loc2 = make_loc('madagascar', domain=cls.ccdomain.name, type="district") cls.ccuser_1 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', created_by=None, created_via=None, email='*****@*****.**', ) cls.ccuser_1.set_location(cls.loc1) cls.ccuser_1.save() cls.ccuser_2 = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', created_by=None, created_via=None, email='*****@*****.**', ) cls.ccuser_2.set_role(cls.ccdomain.name, cls.custom_role.get_qualified_id()) cls.ccuser_2.set_location(cls.loc2) cls.ccuser_2.save() cls.web_user = WebUser.create( domain=cls.ccdomain.name, username='******', password='******', created_by=None, created_via=None, email='*****@*****.**', ) cls.ccuser_other_domain = CommCareUser.create( domain=cls.other_domain.name, username='******', password='******', created_by=None, created_via=None, email='*****@*****.**', ) cls.retired_user = CommCareUser.create( domain=cls.ccdomain.name, username='******', password='******', created_by=None, created_via=None, email='*****@*****.**', ) cls.retired_user.retire(deleted_by=None)