Skip to content

Commit

Permalink
[db] Remove TestCaseText model, merge into TestCase.text field
Browse files Browse the repository at this point in the history
- TestCaseText model is removed and provided as TestCase.text field
- TestCase.latest_text() is removed in favor of TestCase.text
- TestCase.latest_text_version() is removed in favor of
  TestCase.history.latest().history_id
- TestCase.get_text_with_version() will read from the history
- TestCase.add_text() is removed
- TestCase.get_text_versions() - removed
- TestCaseRun.latest_text() is removed
- TestCaseRun.get_text_with_version() is removed in favor of
  TestCase.get_text_with_version()
- NoneText is removed
- tcms.core.utils.checksum is removed
- tcms.utils.dict_utils is removed
- update existing templates and forms
- update test suite to generate historical records

Closes #198
  • Loading branch information
atodorov committed Jan 20, 2019
1 parent 571d6f2 commit 5750b34
Show file tree
Hide file tree
Showing 28 changed files with 166 additions and 583 deletions.
10 changes: 0 additions & 10 deletions tcms/core/utils/checksum.py

This file was deleted.

37 changes: 9 additions & 28 deletions tcms/issuetracker/types.py
Expand Up @@ -155,19 +155,14 @@ def report_issue_from_testcase(self, caserun):
args = {}
args['cf_build_id'] = caserun.run.build.name

# this is a TestCaseText model or NoneText
txt = caserun.get_text_with_version(case_text_version=caserun.case_text_version)
setup = txt.setup
action = txt.action
effect = txt.effect
txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)

comment = "Filed from caserun %s\n\n" % caserun.get_full_url()
comment += "Version-Release number of selected " \
"component (if applicable):\n"
comment += '%s\n\n' % caserun.build.name
comment += "Steps to Reproduce: \n%s\n%s\n\n" % (setup, action)
comment += "Steps to Reproduce: \n%s\n\n" % txt
comment += "Actual results: \n<describe what happened>\n\n"
comment += "Expected results:\n%s\n\n" % effect

args['comment'] = comment
args['component'] = caserun.case.component.values_list('name',
Expand Down Expand Up @@ -256,21 +251,17 @@ def report_issue_from_testcase(self, caserun):
args['reporter'] = self.rpc.user(tested_by.username).key
except jira.JIRAError:
pass
# this is a TestCaseText model or NoneText
txt = caserun.get_text_with_version(case_text_version=caserun.case_text_version)
setup = txt.setup
action = txt.action
effect = txt.effect

txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)

comment = "Filed from caserun %s\n\n" % caserun.get_full_url()
comment += "Product:\n%s\n\n" % caserun.run.plan.product.name
comment += "Component(s):\n%s\n\n" % caserun.case.component.values_list('name', flat=True)
comment += "Version-Release number of selected " \
"component (if applicable):\n"
comment += "%s\n\n" % caserun.build.name
comment += "Steps to Reproduce: \n%s\n%s\n\n" % (setup, action)
comment += "Steps to Reproduce: \n%s\n\n" % txt
comment += "Actual results: \n<describe what happened>\n\n"
comment += "Expected results:\n%s\n\n" % effect
args['description'] = comment

url = self.tracker.base_url
Expand Down Expand Up @@ -321,21 +312,16 @@ def report_issue_from_testcase(self, caserun):
'title': 'Failed test: %s' % caserun.case.summary,
}

# this is a TestCaseText model or NoneText
txt = caserun.get_text_with_version(case_text_version=caserun.case_text_version)
setup = txt.setup
action = txt.action
effect = txt.effect
txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)

comment = "Filed from caserun %s\n\n" % caserun.get_full_url()
comment += "Product:\n%s\n\n" % caserun.run.plan.product.name
comment += "Component(s):\n%s\n\n" % caserun.case.component.values_list('name', flat=True)
comment += "Version-Release number of selected " \
"component (if applicable):\n"
comment += "%s\n\n" % caserun.build.name
comment += "Steps to Reproduce: \n%s\n%s\n\n" % (setup, action)
comment += "Steps to Reproduce: \n%s\n\n" % txt
comment += "Actual results: \n<describe what happened>\n\n"
comment += "Expected results:\n%s\n\n" % effect
args['body'] = comment

url = self.tracker.base_url
Expand Down Expand Up @@ -371,11 +357,7 @@ def report_issue_from_testcase(self, caserun):
'issue[title]': 'Failed test: %s' % caserun.case.summary,
}

# this is a TestCaseText model or NoneText
txt = caserun.get_text_with_version(case_text_version=caserun.case_text_version)
setup = txt.setup
action = txt.action
effect = txt.effect
txt = caserun.case.get_text_with_version(case_text_version=caserun.case_text_version)

comment = "Filed from caserun %s\n\n" % caserun.get_full_url()
comment += "**Product**:\n%s\n\n" % caserun.run.plan.product.name
Expand All @@ -384,9 +366,8 @@ def report_issue_from_testcase(self, caserun):
comment += "Version-Release number of selected " \
"component (if applicable):\n"
comment += "%s\n\n" % caserun.build.name
comment += "**Steps to Reproduce**: \n%s\n%s\n\n" % (setup, action)
comment += "**Steps to Reproduce**: \n%s\n\n" % txt
comment += "**Actual results**: \n<describe what happened>\n\n"
comment += "**Expected results**:\n%s\n\n" % effect
args['issue[description]'] = comment

url = self.tracker.base_url
Expand Down
31 changes: 1 addition & 30 deletions tcms/templates/case/edit.html
Expand Up @@ -46,13 +46,6 @@

{% block contents %}
<div id="content">
<span class="right-action">
{% if test_case %}
<a href="{% url "testcases-text_history" test_case.case_id %}?from_plan={{ test_plan.plan_id }}" class="historylink">
Edit History
</a>
{% endif %}
</span>
{% if test_case %}
<form action="{% url "testcases-edit" test_case.case_id %}" method="post">
{% else %}
Expand Down Expand Up @@ -113,24 +106,10 @@
{% endif %}
</div>
</div>
<div class="data_row">
<label >Last Editor</label>
<div id="display_editor">
{% if test_case.latest_text.author %}
<a href="{% url "tcms-profile" test_case.latest_text.author.username %}">
{{ test_case.latest_text.author.username }}
</a>
{% endif %}
</div>
</div>
<div class="data_row">
<label >Created</label>
<div class="name">{{ test_case.create_date }}</div>
</div>
<div class="data_row">
<label >Last Modified</label>
<div id="display_modify_date" >{{ test_case.latest_text.create_date }}</div>
</div>
{% endif %}

<div class="data_row">
Expand All @@ -157,15 +136,7 @@
<fieldset class="no-border background-light-grey">
<div class="editor-side">
<h4 class="strong">Setup</h4>
<div class="form" id="form_setup">{{ form.setup }}</div>
<h4 class="strong">Actions</h4>
<div class="form" id="form_action">{{ form.action }}</div>
</div>
<div class="editor-side">
<h4 class="strong">Break down</h4>
<div class="" id="form_breakdown">{{ form.breakdown }}</div>
<h4 class="strong">Expected Results</h4>
<div class="" id="form_effect">{{ form.effect }}</div>
<div class="form" id="form_text">{{ form.text }}</div>
</div>
</fieldset>
{% if notify_form %}
Expand Down
20 changes: 3 additions & 17 deletions tcms/templates/case/get_details.html
Expand Up @@ -3,13 +3,9 @@
<td id="id_case_text_{{ forloop.counter }}" colspan="12">
<table class="case_detail">
<tr>
<td valign="top">
<h4>Setup:</h4>
<div class="content">{{ test_case_text.setup|markdown2html }}</div>
</td>
<td class="" valign="top">
<h4>Breakdown:</h4>
<div class="content">{{ test_case_text.breakdown|markdown2html }}</div>
<td valign="top" colspan='2'>
<h4>Text:</h4>
<div class="content">{{ test_case.text|markdown2html }}</div>
</td>
<td valign="top" rowspan="2" width="200">
<h4><span class="title strong">Attachment:</span></h4>
Expand Down Expand Up @@ -56,16 +52,6 @@ <h4><span class="title strong">bug:</span></h4>
</ul>
</td>
</tr>
<tr>
<td class="" valign="top">
<h4>Actions:</h4>
<div class="content">{{ test_case_text.action|markdown2html }}</div>
</td>
<td class="" valign="top">
<h4>Expected Results:</h4>
<div class="content">{{ test_case_text.effect|markdown2html }}</div>
</td>
</tr>
<tr>
<td colspan='3'>
<h4>Notes:</h4>
Expand Down
29 changes: 3 additions & 26 deletions tcms/templates/case/get_details_case_run.html
Expand Up @@ -129,33 +129,10 @@ <h4 class="borderB">Change Log</h4>
<div class="caseInfo">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<td colspan='3'>
<div class="container">
<h4>Setup</h4>
<div class="content">{{ test_case_text.setup|markdown2html }}</div>
</div>
</td>
<td style="width:5px;"></td>
<td>
<div class="container">
<h4>Breakdown</h4>
<div class="content">{{ test_case_text.breakdown|markdown2html }}</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="container">
<h4>Actions</h4>
<div class="content">{{ test_case_text.action|markdown2html }}</div>
</div>

</td>
<td style="width:5px;"></td>
<td>
<div class="container">
<h4>Expected Results</h4>
<div class="content">{{ test_case_text.effect|markdown2html }}</div>
<h4>Text</h4>
<div class="content">{{ test_case_text|markdown2html }}</div>
</div>
</td>
</tr>
Expand Down
65 changes: 0 additions & 65 deletions tcms/templates/case/history.html

This file was deleted.

21 changes: 3 additions & 18 deletions tcms/templates/case/printable.html
Expand Up @@ -47,28 +47,13 @@ <h2 id="plan_document">Test Plan Document</h2>
<div>
<h2 id="plan_cases">Test Cases</h2>
<div class="thick-line"></div>
{% for case_id, test_cases in test_cases.items %}
{% for test_case in test_cases %}
<div style="clear: left">
{% for test_case in test_cases %}
<h3>TC-{{ test_case.case_id }}: {{ test_case.case__summary }}</h3>
<h3>TC-{{ test_case.case_id }}: {{ test_case.summary }}</h3>
<div class="thin-line"></div>
<div class="case-stage">
<h4>Set up</h4>
{{ test_case.setup|markdown2html }}
{{ test_case.text|markdown2html }}
</div>
<div class="case-stage">
<h4>Actions</h4>
{{ test_case.action|markdown2html }}
</div>
<div class="case-stage">
<h4>Expected Results</h4>
{{ test_case.effect|markdown2html }}
</div>
<div class="case-stage">
<h4>Breakdown</h4>
{{ test_case.breakdown|markdown2html }}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
Expand Down
5 changes: 1 addition & 4 deletions tcms/testcases/forms.py
Expand Up @@ -105,10 +105,7 @@ class BaseCaseForm(forms.Form):
widget=forms.Textarea,
required=False
)
setup = forms.CharField(label="Setup", widget=SimpleMDE(), required=False)
action = forms.CharField(label="Actions", widget=SimpleMDE(), required=False)
effect = forms.CharField(label="Expect results", widget=SimpleMDE(), required=False)
breakdown = forms.CharField(label="Breakdown", widget=SimpleMDE(), required=False)
text = forms.CharField(widget=SimpleMDE(), required=False)

def __init__(self, *args, **kwargs):
if args:
Expand Down

0 comments on commit 5750b34

Please sign in to comment.