Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add field for test result preview #27

Merged
merged 1 commit into from
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion authentication/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ExtUserSerializer(serializers.ModelSerializer):
class Meta:
model = ExtUser
fields = ('default_project', 'launches_on_page',
'testresults_on_page', 'dashboards')
'testresults_on_page', 'dashboards', 'result_preview')


class AccountSerializer(serializers.ModelSerializer):
Expand Down
21 changes: 21 additions & 0 deletions authentication/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def test_get_default_settings(self):
self.assertEqual(25, content['settings']['testresults_on_page'])
self.assertFalse(content['settings']['default_project'])
self.assertEqual([], content['settings']['dashboards'])
self.assertFalse(content['settings']['result_preview'])

def test_update(self):
c = Client()
Expand All @@ -106,6 +107,26 @@ def test_update(self):
self.assertEqual(1, content['settings']['default_project'])
self.assertEqual([], content['settings']['dashboards'])

def test_update_preview(self):
c = Client()
c.post('/api/auth/login/',
data=json.dumps({
'username': self.user_login,
'password': self.user_plain_password}),
content_type='application/json')

response = c.post('/api/auth/update',
data=json.dumps({
'result_preview': 'tail'}),
content_type='application/json')
self.assertEqual(response.status_code, 200)

response = c.get('/api/auth/get')
self.assertEqual(response.status_code, 200)
content = json.loads(
response.content.decode('utf-8', errors='replace'))
self.assertEqual('tail', content['settings']['result_preview'])

def test_update_dashboards(self):
c = Client()
c.post('/api/auth/login/',
Expand Down
20 changes: 20 additions & 0 deletions testreport/migrations/0040_extuser_result_preview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('testreport', '0039_auto_20160120_1606'),
]

operations = [
migrations.AddField(
model_name='extuser',
name='result_preview',
field=models.CharField(blank=True, default=None, max_length=128, verbose_name='Result preview', choices=[('head', 'Show test result head'), ('tail', 'Show test result tail')], null=True),
preserve_default=True,
),
]
8 changes: 8 additions & 0 deletions testreport/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
LAUNCH_TYPES = (ASYNC_CALL, INIT_SCRIPT, CONCLUSIVE) = (0, 1, 2)
CELERY_FINISHED_STATES = (states.SUCCESS, states.FAILURE)

RESULT_PREVIEW_CHOICES = (
('head', 'Show test result head'),
('tail', 'Show test result tail')
)


class ExtUser(models.Model):
user = models.OneToOneField(User, related_name='settings')
Expand All @@ -28,6 +33,9 @@ class ExtUser(models.Model):
testresults_on_page = models.IntegerField(
_('Testresults on page'), default=25)
dashboards = models.TextField(_('Dashboards'), default='[]')
result_preview = models.CharField(_('Result preview'), max_length=128,
choices=RESULT_PREVIEW_CHOICES,
blank=True, null=True, default=None)

def get_dashboards(self):
if self.dashboards == '""' or self.dashboards is None:
Expand Down