Skip to content

Commit

Permalink
Add regression test for #2783
Browse files Browse the repository at this point in the history
  • Loading branch information
lunkwill42 committed Dec 11, 2023
1 parent b51ca9d commit 869a044
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/integration/web/maintenance/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# more details. You should have received a copy of the GNU General Public
# License along with NAV. If not, see <http://www.gnu.org/licenses/>.
#
import datetime

import pytest
from django.urls import reverse

from nav.compatibility import smart_str
from nav.models.manage import Netbox
from nav.models.msgmaint import MaintenanceTask
Expand Down Expand Up @@ -136,3 +139,27 @@ def test_with_end_time_before_start_time_should_fail(self, db, client, localhost
assert not MaintenanceTask.objects.filter(
description=data["description"]
).exists()


class TestEditMaintenanceTask:
def test_when_existing_task_is_requested_it_should_render_with_intact_description(
self, db, client, localhost, empty_maintenance_task
):
url = reverse("maintenance-edit", kwargs={"task_id": empty_maintenance_task.id})
response = client.get(url, follow=True)

assert response.status_code == 200
assert empty_maintenance_task.description in smart_str(response.content)


@pytest.fixture
def empty_maintenance_task(db):
now = datetime.datetime.now()
task = MaintenanceTask(
start_time=now,
end_time=now + datetime.timedelta(hours=1),
description="Temporary test fixture task",
)
task.save()
yield task
task.delete()

0 comments on commit 869a044

Please sign in to comment.