Skip to content

Commit

Permalink
Fix tests and add test structure or none related infra
Browse files Browse the repository at this point in the history
  • Loading branch information
LePetitTim committed Nov 27, 2018
1 parent 9558744 commit 3daeb9d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions geotrek/infrastructure/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def tearDown(self):
self.client.logout()
self.user.delete()

def test_infrastructuretype_can_be_change(self):
def test_infrastructurecondition_can_be_change(self):
self.login()

change_url = reverse('admin:infrastructure_infrastructurecondition_change', args=[self.infra.pk])
Expand All @@ -66,7 +66,7 @@ def test_infrastructuretype_can_be_change(self):

self.assertEqual(response.url, '/admin/infrastructure/infrastructurecondition/')

def test_infrastructuretype_changelist(self):
def test_infrastructurecondition_changelist(self):
self.login()
changelist_url = reverse('admin:infrastructure_infrastructurecondition_changelist')
response = self.client.get(changelist_url)
Expand Down
21 changes: 21 additions & 0 deletions geotrek/infrastructure/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def test_description_in_detail_page(self):
response = self.client.get(infra.get_detail_url())
self.assertContains(response, "<b>Beautiful !</b>")

def test_check_structure_or_none_related_are_visible(self):
self.login()
infratype = InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.BUILDING, structure=None)
response = self.client.get(self.model.get_add_url())
self.assertEqual(response.status_code, 200)
self.assertTrue('form' in response.context)
form = response.context['form']
type = form.fields['type']
self.assertTrue((infratype.pk, unicode(infratype)) in type.choices)


class PointInfrastructureViewsTest(InfrastructureViewsTest):
def get_good_data(self):
Expand All @@ -70,13 +80,24 @@ def get_good_data(self):
class SignageViewsTest(InfrastructureViewsTest):
model = Signage
modelfactory = SignageFactory
userfactory = PathManagerFactory

def get_good_data(self):
data = super(SignageViewsTest, self).get_good_data()
data['type'] = InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.SIGNAGE).pk
data['condition'] = InfrastructureConditionFactory.create().pk
return data

def test_check_structure_or_none_related_are_visible(self):
self.login()
infratype = InfrastructureTypeFactory.create(type=INFRASTRUCTURE_TYPES.SIGNAGE, structure=None)
response = self.client.get(self.model.get_add_url())
self.assertEqual(response.status_code, 200)
self.assertTrue('form' in response.context)
form = response.context['form']
type = form.fields['type']
self.assertTrue((infratype.pk, unicode(infratype)) in type.choices)


class InfrastructureTypeTest(TestCase):
def test_manager(self):
Expand Down

0 comments on commit 3daeb9d

Please sign in to comment.