ojuso-map/apps/map/tests.py

50 lines
2.5 KiB
Python
Raw Normal View History

2017-05-19 00:23:40 +00:00
from django.test import TestCase
from .models import CaseStudy
class CaseStudyTests(TestCase):
def test_get_renewable_generation_detail_when_empty(self):
"""get_renewable_generation_detail() should return the empty string."""
case_study = CaseStudy()
self.assertIs(case_study.get_renewable_generation_detail(), "")
def test_get_renewable_generation_detail_with_geo(self):
"""get_renewable_generation_detail() should return just the description"""
case_study = CaseStudy(generation_technology='GEOT')
self.assertEqual(case_study.get_renewable_generation_detail(), "Geothermal electricity")
def test_get_renewable_generation_detail_with_wind(self):
"""get_renewable_generation_detail() should return the description prefixed with 'wind power'"""
case_study = CaseStudy(generation_technology='SSWE')
self.assertEqual(case_study.get_renewable_generation_detail(), "Wind energy Small-scale (less than 500kW)")
def test_get_renewable_generation_detail_with_other(self):
"""get_renewable_generation_detail() should return the detail provided in .generation_technology_other"""
case_study = CaseStudy(generation_technology='OTHR', generation_technology_other='Warp drive')
self.assertEqual(case_study.get_renewable_generation_detail(), "Warp drive")
# These tests are commented out because they are not working, but the code
# in production is. When running as a test, get_negative_case_reasons_no_other()
# is returning a list of coded options, like
# ['V', 'O', 'L', 'R', ',', 'A', 'L', 'A', 'B']
# instead of a list of text like
# ['Violation of land rights', 'Abusive labour practices']
#  I am too much of a Django newbie to know why.  Anna
# def test_get_negative_case_reasons_no_other_1(self):
# """Test with case having no 'other' entry"""
# case_study = CaseStudy(negative_case_reasons='VOLR,ALAB')
# self.assertEqual(case_study.get_negative_case_reasons_no_other(),
# [ 'Violation of land rights'
# , 'Abusive labour practices'
# ])
#
# def test_get_negative_case_reasons_no_other_2(self):
# """Test with case having an 'other' entry"""
# case_study = CaseStudy(negative_case_reasons='VOLR,ALAB,OTHR')
# self.assertEqual(case_study.get_negative_case_reasons_no_other(),
# [ 'Violation of land rights'
# , 'Abusive labour practices'
# ])