add more meaningful test object names

This commit is contained in:
Andreas Zweili 2019-07-13 15:48:17 +02:00
parent a30fbd1c63
commit 68e3bbeb4b
1 changed files with 28 additions and 28 deletions

View File

@ -9,52 +9,52 @@ from inventory.models import Customer, Computer
def create_users(): def create_users():
User = get_user_model() User = get_user_model()
customer_c = User.objects.create_user('customer_c', novartis = User.objects.create_user('novartis_admin',
'c@ccompany.com', 'novartis_admin@novartis.com',
'password', 'password',
is_staff=True) is_staff=True)
customer_h = User.objects.create_user('customer_h', nestle = User.objects.create_user('nestle_admin',
'h@hcompany.com', 'nestle_admin@nestle.com',
'password', 'password',
is_staff=True) is_staff=True)
return customer_c, customer_h return novartis, nestle
def create_groups(): def create_groups():
cadmin = Group.objects.create(name='CAdmin') novartis_admin_group = Group.objects.create(name='NovartisAdmins')
hadmin = Group.objects.create(name='HAdmin') nestle_admin_group = Group.objects.create(name='NestleAdmins')
return cadmin, hadmin return novartis_admin_group, nestle_admin_group
def create_customers(): def create_customers():
c = Customer.objects.create(name='C') novartis = Customer.objects.create(name='Novartis')
h = Customer.objects.create(name='H') nestle = Customer.objects.create(name='Nestle')
return c, h return novartis, nestle
def create_computers(): def create_computers():
Computer.objects.create(name='c-pc1', Computer.objects.create(name='novartis-pc1',
customer=Customer.objects.get(name='C')) customer=Customer.objects.get(name='Novartis'))
Computer.objects.create(name='h-pc1', Computer.objects.create(name='nestle-pc1',
customer=Customer.objects.get(name='H')) customer=Customer.objects.get(name='Nestle'))
@pytest.mark.django_db @pytest.mark.django_db
def test_something(): def test_something():
cadmin, hadmin = create_groups() novartis_admin_group, nestle_admin_group = create_groups()
customer_c, customer_h = create_users() novartis_admin, nestle_admin = create_users()
c, h = create_customers() novartis, nestle = create_customers()
create_computers() create_computers()
customer_c.groups.add(cadmin) novartis_admin.groups.add(novartis_admin_group)
customer_h.groups.add(hadmin) nestle_admin.groups.add(nestle_admin_group)
assign_perm('view_customer', cadmin, c) assign_perm('view_customer', novartis_admin, novartis)
assign_perm('view_customer', hadmin, h) assign_perm('view_customer', nestle_admin, nestle)
c_client = Client() novartis_client = Client()
h_client = Client() nestle_client = Client()
response = c_client.post('/admin/', response = novartis_client.post('/admin/',
{'username': 'customer_c', {'username': 'novartis_admin',
'password': 'password'}) 'password': 'password'})
response = c_client.get('/') response = novartis_client.get('/')
print(response.content) print(response.content)
assert False assert False