Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aptivate
client-projects
internewshid
Commits
e7ea21f3
Commit
e7ea21f3
authored
9 years ago
by
Alice Heaton
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests after renaming of widget, and add new tests for the term count chart widget.
parent
23e911ba
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
django/website/hid/tests/chart_widget_tests.py
+0
-41
0 additions, 41 deletions
django/website/hid/tests/chart_widget_tests.py
django/website/hid/tests/term_count_widget_tests.py
+101
-0
101 additions, 0 deletions
django/website/hid/tests/term_count_widget_tests.py
with
101 additions
and
41 deletions
django/website/hid/tests/chart_widget_tests.py
deleted
100644 → 0
+
0
−
41
View file @
23e911ba
from
django.test
import
TestCase
from
hid.widgets.chart
import
QuestionChartWidget
class
TestQuestionChartWidget
(
TestCase
):
def
test_context_data_includes_widget_name
(
self
):
widget
=
QuestionChartWidget
()
context_data
=
widget
.
get_context_data
(
name
=
'
test-name
'
,
questions
=
{})
self
.
assertEqual
(
context_data
[
'
name
'
],
'
test-name
'
)
def
test_context_data_includes_flot_options
(
self
):
widget
=
QuestionChartWidget
()
context_data
=
widget
.
get_context_data
(
name
=
'
test-name
'
,
questions
=
{})
self
.
assertTrue
(
'
options
'
in
context_data
)
def
test_context_data_includes_flot_data
(
self
):
widget
=
QuestionChartWidget
()
context_data
=
widget
.
get_context_data
(
name
=
'
test-name
'
,
questions
=
{})
self
.
assertTrue
(
'
data
'
in
context_data
)
def
test_context_data_includes_correct_data
(
self
):
widget
=
QuestionChartWidget
()
context_data
=
widget
.
get_context_data
(
name
=
'
test-name
'
,
questions
=
{
'
question one
'
:
345
,
'
question two
'
:
782
})
self
.
assertEqual
(
context_data
[
'
data
'
],
[[[
345
,
0
],
[
782
,
1
]]]
)
def
test_chart_questions_are_set_as_yaxis_value_labels
(
self
):
widget
=
QuestionChartWidget
()
context_data
=
widget
.
get_context_data
(
name
=
'
test-name
'
,
questions
=
{
'
question one
'
:
345
,
'
question two
'
:
782
})
self
.
assertEqual
(
context_data
[
'
options
'
][
'
yaxis
'
][
'
ticks
'
],
[[
0
,
'
question one
'
],
[
1
,
'
question two
'
]]
)
This diff is collapsed.
Click to expand it.
django/website/hid/tests/term_count_widget_tests.py
0 → 100644
+
101
−
0
View file @
e7ea21f3
from
mock
import
patch
from
django.test
import
TestCase
from
hid.widgets.term_count_chart
import
TermCountChartWidget
class
TestTermCountChartWidget
(
TestCase
):
def
test_context_data_includes_widget_title
(
self
):
widget
=
TermCountChartWidget
()
with
patch
(
'
hid.widgets.term_count_chart.term_itemcount
'
)
as
itemcount
:
itemcount
.
return_value
=
[]
context_data
=
widget
.
get_context_data
(
title
=
'
test-name
'
,
taxonomy
=
'
tax
'
)
self
.
assertEqual
(
context_data
[
'
title
'
],
'
test-name
'
)
def
test_context_data_includes_flot_options
(
self
):
widget
=
TermCountChartWidget
()
with
patch
(
'
hid.widgets.term_count_chart.term_itemcount
'
)
as
itemcount
:
itemcount
.
return_value
=
[]
context_data
=
widget
.
get_context_data
(
title
=
'
test-name
'
,
taxonomy
=
'
tax
'
)
self
.
assertTrue
(
'
options
'
in
context_data
)
def
test_context_data_includes_flot_data
(
self
):
widget
=
TermCountChartWidget
()
with
patch
(
'
hid.widgets.term_count_chart.term_itemcount
'
)
as
itemcount
:
itemcount
.
return_value
=
[]
context_data
=
widget
.
get_context_data
(
title
=
'
test-name
'
,
taxonomy
=
'
tax
'
)
self
.
assertTrue
(
'
data
'
in
context_data
)
def
test_context_data_includes_correct_data
(
self
):
widget
=
TermCountChartWidget
()
with
patch
(
'
hid.widgets.term_count_chart.term_itemcount
'
)
as
itemcount
:
itemcount
.
return_value
=
[
{
'
name
'
:
'
name one
'
,
'
long_name
'
:
'
long name one
'
,
'
count
'
:
345
},
{
'
name
'
:
'
name two
'
,
'
long_name
'
:
'
long name two
'
,
'
count
'
:
782
},
]
context_data
=
widget
.
get_context_data
(
title
=
'
test-name
'
,
taxonomy
=
'
tax
'
)
self
.
assertEqual
(
context_data
[
'
data
'
],
[[[
345
,
2
],
[
782
,
1
]]]
)
def
test_chart_questions_are_set_as_yaxis_value_labels
(
self
):
widget
=
TermCountChartWidget
()
with
patch
(
'
hid.widgets.term_count_chart.term_itemcount
'
)
as
itemcount
:
itemcount
.
return_value
=
[
{
'
name
'
:
'
name one
'
,
'
long_name
'
:
'
long name one
'
,
'
count
'
:
345
},
{
'
name
'
:
'
name two
'
,
'
long_name
'
:
'
long name two
'
,
'
count
'
:
782
},
]
context_data
=
widget
.
get_context_data
(
title
=
'
test-name
'
,
taxonomy
=
'
tax
'
)
self
.
assertEqual
(
context_data
[
'
options
'
][
'
yaxis
'
][
'
ticks
'
],
[[
2
,
'
long name one
'
],
[
1
,
'
long name two
'
]]
)
def
test_fetch_counts_orders_by_long_name
(
self
):
widget
=
TermCountChartWidget
()
with
patch
(
'
hid.widgets.term_count_chart.term_itemcount
'
)
as
itemcount
:
itemcount
.
return_value
=
[
{
'
name
'
:
'
aaa-name
'
,
'
long_name
'
:
'
zzz-long-name
'
,
'
count
'
:
0
},
{
'
name
'
:
'
zzz-name
'
,
'
long_name
'
:
'
aaa-long-name
'
,
'
count
'
:
1000
},
]
counts
=
widget
.
_fetch_counts
(
'
tax
'
,
0
,
'
Others
'
)
self
.
assertEqual
(
counts
.
items
(),
[(
'
aaa-long-name
'
,
1000
),
(
'
zzz-long-name
'
,
0
)]
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment