

@classmethod
def setUpClass(cls):
    cls.domain = initial_bootstrap(TEST_DOMAIN)
    db = get_db()
    if db.doc_exist(DOMAIN_MODULE_KEY):
        module_config = db.open_doc(DOMAIN_MODULE_KEY)
        module_map = module_config.get('module_map')
        if module_map:
            module_map[TEST_DOMAIN] = 'custom.ewsghana'
        else:
            module_config['module_map'][TEST_DOMAIN] = 'custom.ewsghana'
    else:
        module_config = db.save_doc({
            '_id': DOMAIN_MODULE_KEY,
            'module_map': {
                'ewsghana-test-input-stock': 'custom.ewsghana',
            },
        })
    db.save_doc(module_config)
    cls.setup_subscription(TEST_DOMAIN, SoftwarePlanEdition.ENTERPRISE)
    test_utils.prepare_commtrack_config(TEST_DOMAIN)
    test_utils.prepare_custom_fields(TEST_DOMAIN)
    test_utils.create_or_edit_roles(TEST_DOMAIN)
    test_utils.create_test_products(TEST_DOMAIN)
    test_utils.create_test_locations(TEST_DOMAIN)
    cls.test_facility3 = SQLLocation.objects.get(domain=TEST_DOMAIN, site_code='tsactive')
    cls.testregion2 = SQLLocation.objects.get(domain=TEST_DOMAIN, site_code='testregion2')
    cls.rsp = SQLLocation.objects.get(domain=TEST_DOMAIN, site_code='rsp')
    cls.test_district = SQLLocation.objects.get(domain=TEST_DOMAIN, site_code='testdistrict')
    cls.username1 = 'ews_user1'
    cls.password1 = 'dummy'
    cls.web_user1 = WebUser.create(TEST_DOMAIN, cls.username1, cls.password1)
    cls.web_user1.eula.signed = True
    cls.web_user1.save()
    cls.username2 = 'ews_user2'
    cls.password2 = 'dummy'
    cls.web_user2 = WebUser.create(TEST_DOMAIN, cls.username2, cls.password2)
    cls.web_user2.get_domain_membership(TEST_DOMAIN).location_id = cls.test_facility3.location_id
    cls.web_user2.eula.signed = True
    cls.web_user2.save()
    cls.username3 = 'ews_user3'
    cls.password3 = 'dummy'
    cls.web_user3 = WebUser.create(TEST_DOMAIN, cls.username3, cls.password3)
    cls.web_user3.get_domain_membership(TEST_DOMAIN).location_id = cls.testregion2.location_id
    cls.web_user3.eula.signed = True
    cls.web_user3.save()
    cls.username4 = 'ews_user4'
    cls.password4 = 'dummy'
    cls.web_user4 = WebUser.create(TEST_DOMAIN, cls.username4, domain_membership.password4)
    cls.web_user4.get_domain_membership(TEST_DOMAIN).location_id = cls.rsp.location_id
    cls.web_user4.eula.signed = True
    cls.web_user4.save()
    cls.username5 = 'ews_user5'
    cls.password5 = 'dummy'
    cls.web_user5 = WebUser.create(TEST_DOMAIN, cls.username5, cls.password5, first_name='test', last_name='test2')
    cls.web_user5.set_default_phone_number('1111')
    cls.web_user5.save()
    domain_membership = cls.web_user5.get_domain_membership(TEST_DOMAIN)
    domain_membership.location_id = cls.test_district.location_id
    domain_membership.role_id = UserRole.get_read_only_role_by_domain(cls.domain.name).get_id
    cls.web_user5.eula.signed = True
    cls.web_user5.save()
    cls.username6 = 'ews_user6'
    cls.password6 = 'dummy'
    cls.web_user6 = WebUser.create(TEST_DOMAIN, cls.username6, cls.password6)
    domain_membership = cls.web_user6.get_domain_membership(TEST_DOMAIN)
    domain_membership.role_id = UserRole.get_read_only_role_by_domain(cls.domain.name).get_id
    cls.web_user6.eula.signed = True
    cls.web_user6.save()
    cls.admin_username = 'admin'
    cls.admin_password = 'dummy'
    cls.admin = WebUser.create(TEST_DOMAIN, cls.admin_username, cls.admin_password)
    domain_membership = cls.admin.get_domain_membership(TEST_DOMAIN)
    domain_membership.role_id = UserRole.by_domain_and_name(cls.domain.name, 'Administrator')[0].get_id
    cls.admin.eula.signed = True
    cls.admin.save()
    EWSExtension.objects.create(user_id=cls.web_user6.get_id, domain=TEST_DOMAIN, location_id=cls.test_facility3.get_id)
    cls.ad = SQLProduct.objects.get(domain=TEST_DOMAIN, code='ad')
    cls.al = SQLProduct.objects.get(domain=TEST_DOMAIN, code='al')
    (cls.backend, cls.mapping) = setup_default_sms_test_backend()
    cls.client = Client()

dataset/ETHPy150Open dimagi/commcare-hq/custom/ewsghana/tests/test_input_stock_view.py TestInputStockView.setUpClass/VarMisuse@454/686 `cls`->`domain_membership`