-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
391 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,9 @@ def repos(db): | |
|
||
|
||
@pytest.fixture | ||
def package(db): | ||
# TODO(jelle): create own parameter based version | ||
from main.models import Package | ||
print(list(Package.objects.all())) | ||
def package(db, arches, repos): | ||
# TODO: convert to create_package with standard parameters | ||
call_command('loaddata', 'main/fixtures/package.json') | ||
print(list(Package.objects.all())) | ||
|
||
|
||
@pytest.fixture | ||
|
@@ -41,22 +38,23 @@ def staff_groups(db): | |
call_command('loaddata', 'devel/fixtures/staff_groups.json') | ||
|
||
|
||
# TODO: test with non-admin user fixture | ||
@pytest.fixture | ||
def admin_user_profile(admin_user, arches, repos): | ||
profile = UserProfile.objects.create(user=admin_user, | ||
public_email="[email protected]") | ||
def user(django_user_model): | ||
user = django_user_model.objects.create_user(username=USERNAME, password=USERNAME) | ||
yield user | ||
user.delete() | ||
|
||
|
||
@pytest.fixture | ||
def userprofile(user): | ||
profile = UserProfile.objects.create(user=user, | ||
public_email=f'{user.username}@archlinux.org') | ||
yield profile | ||
profile.delete() | ||
|
||
|
||
@pytest.fixture | ||
def user_client(client, django_user_model, groups): | ||
user = django_user_model.objects.create_user(username=USERNAME, password=USERNAME) | ||
profile = UserProfile.objects.create(user=user, | ||
public_email="{}@archlinux.org".format(user.username)) | ||
def user_client(client, user, userprofile, groups): | ||
user.groups.add(Group.objects.get(name='Developers')) | ||
client.login(username=USERNAME, password=USERNAME) | ||
yield client | ||
profile.delete() | ||
user.delete() | ||
return client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,14 @@ | ||
from django.test import TransactionTestCase | ||
from django.contrib.auth.models import User, Group | ||
from devel.models import UserProfile | ||
def test_clock(user_client): | ||
response = user_client.get('/devel/clock/') | ||
assert response.status_code == 200 | ||
|
||
|
||
class DevelView(TransactionTestCase): | ||
fixtures = ['main/fixtures/arches.json', 'main/fixtures/repos.json', | ||
'main/fixtures/package.json'] | ||
def test_profile(user_client): | ||
response = user_client.get('/devel/profile/') | ||
assert response.status_code == 200 | ||
# Test changing | ||
|
||
def setUp(self): | ||
password = 'test' | ||
self.user = User.objects.create_superuser('admin', | ||
'[email protected]', | ||
password) | ||
for name in ['Developers', 'Retired Developers']: | ||
Group.objects.create(name=name) | ||
self.user.groups.add(Group.objects.get(name='Developers')) | ||
self.user.save() | ||
self.profile = UserProfile.objects.create(user=self.user, | ||
public_email="{}@awesome.com".format(self.user.username)) | ||
self.client.post('/login/', { | ||
'username': self.user.username, | ||
'password': password | ||
}) | ||
|
||
def tearDown(self): | ||
self.profile.delete() | ||
self.user.delete() | ||
Group.objects.all().delete() | ||
|
||
def test_clock(self): | ||
response = self.client.get('/devel/clock/') | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_profile(self): | ||
response = self.client.get('/devel/profile/') | ||
self.assertEqual(response.status_code, 200) | ||
# Test changing | ||
|
||
def test_stats(self): | ||
response = self.client.get('/devel/stats/') | ||
self.assertEqual(response.status_code, 200) | ||
def test_stats(user_client): | ||
response = user_client.get('/devel/stats/') | ||
assert response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.