Esempio n. 1
0
 def setUpClass(cls):
     cls.domain = Domain(name='foo')
     cls.domain.save()
     cls.user = CommCareUser.create(cls.domain.name, 'somebody', 'password')
     cls.user_id = cls.user._id
     cls.factory = CaseFactory(domain='foo', case_defaults={'owner_id': cls.user_id})
     ENABLE_LOADTEST_USERS.set('foo', True, namespace='domain')
 def setUpClass(cls):
     cls.domain = Domain(name='foo')
     cls.domain.save()
     cls.user = CommCareUser.create(cls.domain.name, 'somebody', 'password')
     cls.user_id = cls.user._id
     cls.factory = CaseFactory(domain='foo', case_defaults={'owner_id': cls.user_id})
     ENABLE_LOADTEST_USERS.set('foo', True, namespace='domain')
Esempio n. 3
0
 def setUpClass(cls):
     super(LoadtestUserTest, cls).setUpClass()
     cls.domain = Domain(name='foo')
     cls.domain.save()
     cls.user = CommCareUser.create(cls.domain.name, 'somebody', 'password', None, None)
     cls.user_id = cls.user._id
     cls.factory = CaseFactory(domain='foo', case_defaults={'owner_id': cls.user_id})
     ENABLE_LOADTEST_USERS.set('foo', True, namespace=NAMESPACE_DOMAIN)
Esempio n. 4
0
def get_loadtest_factor_for_user(domain, user_id):
    from corehq.apps.users.models import CouchUser, CommCareUser
    if ENABLE_LOADTEST_USERS.enabled(domain) and user_id:
        user = CouchUser.get_by_user_id(user_id, domain=domain)
        if isinstance(user, CommCareUser):
            return user.loadtest_factor or 1
    return 1
Esempio n. 5
0
def get_loadtest_factor_for_user(domain, user_id):
    from corehq.apps.users.models import CouchUser, CommCareUser
    if ENABLE_LOADTEST_USERS.enabled(domain) and user_id:
        user = CouchUser.get_by_user_id(user_id, domain=domain)
        if isinstance(user, CommCareUser):
            return user.loadtest_factor or 1
    return 1
Esempio n. 6
0
 def loadtest_factor(self):
     """
     Gets the loadtest factor for a domain and user. Is always 1 unless
     both the toggle is enabled for the domain, and the user has a non-zero,
     non-null factor set.
     """
     if ENABLE_LOADTEST_USERS.enabled(self.domain):
         return self._loadtest_factor or 1
     return 1
Esempio n. 7
0
def get_loadtest_factor(domain, user):
    """
    Gets the loadtest factor for a domain and user. Is always 1 unless
    both the toggle is enabled for the domain, and the user has a non-zero,
    non-null factor set.
    """
    if domain and ENABLE_LOADTEST_USERS.enabled(domain):
        return getattr(user, 'loadtest_factor', 1) or 1
    return 1
Esempio n. 8
0
def get_loadtest_factor(domain, user):
    """
    Gets the loadtest factor for a domain and user. Is always 1 unless
    both the toggle is enabled for the domain, and the user has a non-zero,
    non-null factor set.
    """
    if domain and ENABLE_LOADTEST_USERS.enabled(domain):
        return getattr(user, 'loadtest_factor', 1) or 1
    return 1
Esempio n. 9
0
 def setUp(self):
     delete_all_cases()
     self.assertTrue(ENABLE_LOADTEST_USERS.enabled('foo'))
 def setUp(self):
     delete_all_cases()
     self.assertTrue(ENABLE_LOADTEST_USERS.enabled('foo'))