Skip to content

Commit

Permalink
Resolves GeoNode#6925: add test for ThesaurusAvailableModelForm
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Feb 5, 2021
1 parent f7496dd commit ba9fb76
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion geonode/base/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from geonode.services.models import Service
from geonode.tests.base import GeoNodeBaseTestSupport
from geonode.base.models import (
ResourceBase, MenuPlaceholder, Menu, MenuItem, Configuration, Thesaurus, ThesaurusKeyword, TopicCategory
ResourceBase, MenuPlaceholder, Menu, MenuItem, Configuration, Thesaurus, ThesaurusKeyword, ThesaurusKeywordLabel, TopicCategory
)
from django.template import Template, Context
from django.contrib.auth import get_user_model
Expand All @@ -56,6 +56,7 @@
from django.core.files import File
from django.core.management import call_command
from django.core.management.base import CommandError
from geonode.base.forms import ThesaurusAvailableForm


test_image = Image.new('RGBA', size=(50, 50), color=(155, 0, 0))
Expand Down Expand Up @@ -891,3 +892,20 @@ def test_get_thesaurus_date(self):
@staticmethod
def __get_last_thesaurus():
return Thesaurus.objects.all().order_by("-id")[0]


class TestThesaurusAvailableForm(GeoNodeBaseTestSupport):
def setUp(self):
self.sut = ThesaurusAvailableForm

def test_form_is_invalid_if_required_fields_are_missing(self):
actual = self.sut(data={})
self.assertFalse(actual.is_valid())

def test_form_is_invalid_if_fileds_send_unexpected_values(self):
actual = self.sut(data={"8": [1,2], "6": 1234})
self.assertFalse(actual.is_valid())

def test_form_is_valid_if_fileds_send_expected_values(self):
actual = self.sut(data={"8": [1, 2], "6": 36})
self.assertTrue(actual.is_valid())

0 comments on commit ba9fb76

Please sign in to comment.