Skip to content

Commit

Permalink
updating testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lluli committed Dec 24, 2024
1 parent 36ddd05 commit bf2ed35
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ <h3 class="govuk-heading-m">
<dt>Data type:</dt>
<dd>{{ data_type|get_key:dataset.data_type }}</dd>
{% if dataset.is_owner == True and dataset.data_type == 1 or dataset.data_type == 2 %}
{% if show_pipeline_failed_message %}
{% if not show_pipeline_failed_message %}
<div>
<dt class="error-message">Last updated:</dt>
<dd class="error-message">One or more tables failed to update</dd>
Expand Down Expand Up @@ -218,10 +218,12 @@ <h3 class="govuk-heading-m">
{% endif %}
</dl>
</div>
{% if dataset.is_owner == True and dataset.data_type == 1 or dataset.data_type == 2 %}
<div >
{% include "partials/data_insights.html" %}
</div>
{% if dataset.is_owner == True %}
{% if dataset.data_type == 1 or dataset.data_type == 2 %}
<div >
{% include "partials/data_insights.html" %}
</div>
{% endif %}
{% endif %}

{% if not dataset.has_access %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<td class="data-insights__cell">Views in the last 28 days</td>
<td class="data-insights__cell">Completed data dictionaries</td>
<td class="data-insights__cell">Outstanding access requests</td>

</tr>
</tbody>
</table>
Expand Down
16 changes: 14 additions & 2 deletions dataworkspace/dataworkspace/tests/datasets/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1453,6 +1453,7 @@ def test_shows_data_insights_on_datasets_and_datacuts_for_owners_and_managers(us
datacut = factories.DataSetFactory.create(
name="Datacut",
type=DataSetType.DATACUT,
information_asset_owner=user,
user_access_type=UserAccessType.REQUIRES_AUTHENTICATION,
)
datacut2 = factories.DataSetFactory.create(
Expand All @@ -1466,7 +1467,7 @@ def test_shows_data_insights_on_datasets_and_datacuts_for_owners_and_managers(us
user_access_type=UserAccessType.REQUIRES_AUTHENTICATION,
)

# Only shows on owned dataset
# Only shows on owned dataset or datacut
response = client.get(reverse("datasets:find_datasets"))
assert response.status_code == 200

Expand All @@ -1481,7 +1482,15 @@ def test_shows_data_insights_on_datasets_and_datacuts_for_owners_and_managers(us
show_pipeline_failed_message=False,
),
expected_search_result(dataset2),
expected_search_result(datacut),
expected_search_result(
datacut,
is_owner=True,
number_of_requests=mock.ANY,
count=mock.ANY,
source_tables_amount=mock.ANY,
filled_dicts=mock.ANY,
show_pipeline_failed_message=False,
),
expected_search_result(datacut2),
expected_search_result(refdataset),
expected_search_result(visualisation),
Expand All @@ -1500,10 +1509,13 @@ def test_pipeline_failure_message_shows_on_data_insights(
information_asset_owner=user,
user_access_type=UserAccessType.REQUIRES_AUTHENTICATION,
)

# Only shows pipeline error on owned datasets
mock_show_pipeline_failed_message_on_dataset._mock_return_value = True
response = client.get(reverse("datasets:find_datasets"))
assert response.status_code == 200
soup = BeautifulSoup(response.content.decode(response.charset))
assert "One or more tables failed to update" in soup.find("dd", class_="error-message")

datasets = [
expected_search_result(
Expand Down

0 comments on commit bf2ed35

Please sign in to comment.