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

A few bug fixes and improvements for the next release #75

Merged
merged 7 commits into from Oct 27, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -22,7 +22,7 @@ FLAKE8_EXCLUDE=.git,*raw_sql.py

.PHONY: flake8
flake8:
@flake8 --exclude=$(FLAKE8_EXCLUDE) tcms *.py
@flake8 --exclude=$(FLAKE8_EXCLUDE) --ignore=E722,E501 tcms *.py


ifeq ($(strip $(TEST_TARGET)),)
Expand Down
6 changes: 6 additions & 0 deletions docs/source/configuration.rst
Expand Up @@ -4,6 +4,12 @@ Kiwi TCMS configuration settings
All sensible settings are defined in ``tcms/settings/common.py``. You will have
to update some of them for your particular production environment.

.. note::

After adjusting settings for your environment you have to configure
Kiwi TCMS via its web interface! As a minimum you have to
:ref:`configure-kiwi-base-url`!

.. literalinclude:: ../../tcms/settings/common.py
:language: python

Expand Down
2 changes: 2 additions & 0 deletions docs/source/guide/admin.rst
Expand Up @@ -13,6 +13,8 @@ The ADMIN tab allows administrators to manage:

|The Administration screen|

.. _configure-kiwi-base-url:

Configure Kiwi's base URL
-------------------------

Expand Down
3 changes: 2 additions & 1 deletion tcms/profiles/models.py
Expand Up @@ -17,7 +17,8 @@ class Meta:
db_table = u'tcms_user_profiles'

def get_im(self):
from forms import IM_CHOICES
# to avoid circular imports
from .forms import IM_CHOICES

if not self.im:
return None
Expand Down
39 changes: 35 additions & 4 deletions tcms/profiles/tests.py
@@ -1,10 +1,43 @@
# -*- coding: utf-8 -*-

from django.contrib.auth.models import User
import http
from django.test import TestCase
from django.urls import reverse

from tcms.profiles.forms import BookmarkForm
from tcms.tests import create_request_user


class TestProfilesView(TestCase):
"""Test the profiles view functionality"""
@classmethod
def setUpClass(cls):
super(TestProfilesView, cls).setUpClass()

cls.tester = create_request_user('tester', 'password')
cls.somebody_else = create_request_user('somebody-else', 'password')

def test_user_can_view_their_own_profile(self):
logged_in = self.client.login(username=self.tester.username, password='password')
self.assertTrue(logged_in)

url = reverse('tcms-profile', args=[self.tester.username])
response = self.client.get(url)

self.assertEqual(http.client.OK, response.status_code)
self.assertContains(response, self.tester.username)
self.assertContains(response, self.tester.email)

def test_user_case_view_profile_of_another_user(self):
logged_in = self.client.login(username=self.tester.username, password='password')
self.assertTrue(logged_in)

url = reverse('tcms-profile', args=[self.somebody_else.username])
response = self.client.get(url)

self.assertEqual(http.client.OK, response.status_code)
self.assertContains(response, self.somebody_else.username)
self.assertContains(response, self.somebody_else.email)


class TestOpenBookmarks(TestCase):
Expand All @@ -14,9 +47,7 @@ class TestOpenBookmarks(TestCase):
def setUpClass(cls):
super(TestOpenBookmarks, cls).setUpClass()

cls.tester = User.objects.create_user(username='bookmark_tester',
email='bookmark_tester@example.com',
password='password')
cls.tester = create_request_user('bookmark_tester', 'password')

bookmark_form = BookmarkForm({
'name': 'plan page',
Expand Down
2 changes: 1 addition & 1 deletion tcms/templates/case/get_details_case_run.html
Expand Up @@ -6,7 +6,7 @@
<div class="container" style="min-height:190px;">
{# {% get_comment_list for test_case_run as case_run_comments %} #}
<h4 style="padding-bottom:3px;">Comments</h4>
{% if perms.comments.add_comment %}
{% if perms.django_comments.add_comment %}
<form class="update_form" method="POST">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
{% get_comment_form for test_case_run as comment_form %}
Expand Down
10 changes: 8 additions & 2 deletions tcms/templates/registration/login.html
Expand Up @@ -52,10 +52,16 @@
<p>
{% if SETTINGS.MOTD_LOGIN %}
{{ SETTINGS.MOTD_LOGIN|safe}}
{% else %}
Please login to get started.
{% endif %}
</p>
<p>
Please login to get started
{% if AUTH_BACKEND.can_register %}
or <a href="{% url "tcms-register" %}" style="color:white;text-decoration:underline">register an account</a>
if you don't have one
{% endif %}
!
</p>
</div><!--/.col-*-->
</div><!--/.row-->
</div><!--/.container-->
Expand Down
41 changes: 40 additions & 1 deletion tcms/testcases/tests.py
Expand Up @@ -2,6 +2,7 @@

import json
import unittest
import http.client
import xml.etree.ElementTree

from datetime import datetime
Expand All @@ -26,6 +27,7 @@
from tcms.testcases.models import TestCaseComponent
from tcms.testcases.models import TestCasePlan
from tcms.testcases.views import ajax_response
from tcms.testruns.models import TestCaseRunStatus
from tcms.tests.factories import ComponentFactory
from tcms.tests.factories import TestBuildFactory
from tcms.tests.factories import TestCaseCategoryFactory
Expand All @@ -36,9 +38,46 @@
from tcms.tests.factories import TestPlanFactory
from tcms.tests.factories import TestRunFactory
from tcms.tests.factories import TestTagFactory
from tcms.tests import BasePlanCase
from tcms.tests import BasePlanCase, BaseCaseRun
from tcms.tests import remove_perm_from_user
from tcms.tests import user_should_have_perm
from tcms.core.contrib.auth.backends import initiate_user_with_default_setups


class TestGetCaseRunDetailsAsDefaultUser(BaseCaseRun):
"""Assert what a default user (non-admin) will see"""

@classmethod
def setUpTestData(cls):
super(TestGetCaseRunDetailsAsDefaultUser, cls).setUpTestData()

def test_user_in_default_group_sees_comments(self):
# test for https://github.com/kiwitcms/Kiwi/issues/74
initiate_user_with_default_setups(self.tester)
self.login_tester()

url = reverse('caserun-detail-pane', args=[self.case_run_1.case_id])
response = self.client.get(
url,
{
'case_run_id': self.case_run_1.pk,
'case_text_version': self.case_run_1.case.latest_text_version()
}
)

self.assertEqual(http.client.OK, response.status_code)

self.assertContains(
response,
'<textarea name="comment" cols="40" required id="id_comment" maxlength="10000" rows="10">\n</textarea>',
html=True)

for status in TestCaseRunStatus.objects.all():
self.assertContains(
response,
"<input type=\"submit\" class=\"btn btn_%s btn_status js-status-button\" title=\"%s\"" % (status.name.lower(), status.name),
html=False
)


class TestMultipleEmailField(unittest.TestCase):
Expand Down