network_inventory/customers/tests/test_customer_detail_view.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

44 lines
1.4 KiB
Python

import pytest
from mixer.backend.django import mixer
from django.test import Client
from django.contrib.auth import get_user_model
from core.tests import helper
pytestmark = pytest.mark.django_db
def test_customer_detail_view_not_logged_in():
response = Client().get('/customer/1/')
assert response.status_code == 302 and 'login' in response.url
def test_customer_detail_view_not_found(create_admin_user):
create_admin_user()
client = Client()
client.login(username="pharma-admin", password="password")
response = client.get('/customer/230/')
assert response.status_code == 404
def test_customer_detail_view(create_admin_user):
fixture = create_admin_user()
customer = fixture['customer']
client = Client()
client.login(username="pharma-admin", password="password")
response = client.get('/customer/' + str(customer.id) + '/')
assert (response.status_code == 200
and helper.in_content(response, customer))
def test_customer_detail_view_no_permissions():
User = get_user_model()
User.objects.create_user("pharma-admin", "admin@pharma.com",
"password", is_staff=True)
client = Client()
customer = mixer.blend('customers.Customer')
client.login(username="pharma-admin", password="password")
response = client.get('/customer/' + str(customer.id) + '/')
assert response.status_code == 302 and 'login' in response.url