network_inventory/conftest.py
Andreas Zweili 6dd0e38513 remove the names of some overly large capitalists
These companies already have far too much money at their disposal.
They might profit from the free advertising appearing in this
repository and we wouldn't want that wouldn't we?
2020-03-15 19:54:43 +01:00

39 lines
1.3 KiB
Python

import pytest
from mixer.backend.django import mixer
from django.core.management import call_command
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from guardian.shortcuts import assign_perm
@pytest.fixture(scope='session')
def django_db_setup(django_db_setup, django_db_blocker):
with django_db_blocker.unblock():
call_command('loaddata', 'backups.yaml')
call_command('loaddata', 'computers.yaml')
call_command('loaddata', 'core.yaml')
call_command('loaddata', 'devices.yaml')
call_command('loaddata', 'nets.yaml')
call_command('loaddata', 'softwares.yaml')
@pytest.fixture
def create_admin_user():
def _create_admin_user():
User = get_user_model()
admin = User.objects.create_user("pharma-admin",
"admin@pharma.com",
"password",
is_staff=True)
customer = mixer.blend('customers.Customer')
group = Group.objects.create(name="Pharma Corp. Admin")
admin.groups.add(group)
assign_perm('view_customer', admin, customer)
result = {}
result['admin'] = admin
result['customer'] = customer
result['group'] = group
return result
return _create_admin_user