Commit 2c130acf authored by Michal Čihař's avatar Michal Čihař

Fix test to use migrations

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 80e7a9b1
......@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from django.contrib.auth.models import User
from django.contrib.auth.models import User, Group
from django.core.cache import cache
from django.core.urlresolvers import reverse
......@@ -66,6 +66,8 @@ class APIBaseTest(APITestCase, RepoTestMixin):
def authenticate(self, superuser=False):
user, dummy = User.objects.get_or_create(username='test')
group = Group.objects.get(name='Users')
user.groups.add(group)
user.is_superuser = superuser
user.save()
cache.delete(get_acl_cache_key(user))
......
......@@ -110,20 +110,6 @@ AUTHENTICATION_BACKENDS = (
'weblate.accounts.auth.WeblateUserBackend',
)
class DisableMigrations(object):
"""Magic to disable migrations"""
def __contains__(self, item):
return True
def __getitem__(self, item):
return "notmigrations"
# Avoid running migrations in testsuite
if 'TEST_MIGRATIONS' not in os.environ:
MIGRATION_MODULES = DisableMigrations()
warnings.filterwarnings(
'error', r"DateTimeField .* received a naive datetime",
RuntimeWarning, r'django\.db\.models\.fields'
......
......@@ -21,6 +21,7 @@
from django.core.management.base import CommandError
from django.contrib.auth.models import User
from weblate.accounts.models import Profile
from weblate.trans.models import SubProject
from weblate.trans.autotranslate import auto_translate
from weblate.trans.management.commands import WeblateTranslationCommand
......@@ -72,6 +73,7 @@ class Command(WeblateTranslationCommand):
# Get user
try:
user = User.objects.get(username=options['user'])
Profile.objects.get_or_create(user=user)
except User.DoesNotExist:
raise CommandError('User does not exist!')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment