def _get_rows(self, section, service_data): return list( filter(not_empty, [ Attribute(value=service_data.get(question['id'], None), question_type=question['type'], label=question['question']) for question in section['questions'] ]))
def test_an_attribute_with_assurance_being_service_provider_assertion( self): attribute = Attribute( { 'value': 'Managed email service', 'assurance': 'Service provider assertion' }, 'text') self.assertEqual(attribute.value, 'Managed email service') self.assertEqual(attribute.assurance, False)
def test_rendering_of_list_with_assurance(self): attribute = Attribute( { "value": ['Gold certification', 'Silver certification'], "assurance": "CESG-assured componenents" }, 'list') self.assertEqual(attribute.value, ['Gold certification', 'Silver certification']) self.assertEqual(attribute.assurance, "CESG-assured componenents")
def test_an_attribute_with_assurance_being_service_provider_assertion(self): attribute = Attribute( { 'value': 'Managed email service', 'assurance': 'Service provider assertion' }, 'text' ) assert attribute.value == 'Managed email service' assert attribute.assurance is False
def test_an_attribute_with_assurance(self): attribute = Attribute( { 'value': 'Managed email service', 'assurance': 'CESG-assured components' }, 'text' ) assert attribute.value == 'Managed email service' assert attribute.assurance == 'CESG-assured components'
def test_get_data_type_handles_empty_data(self): self.assertEqual(Attribute('', 'text').type, 'text') self.assertEqual(Attribute('', 'text').value, '') self.assertEqual(Attribute(None, 'number').type, 'text') self.assertEqual(Attribute(None, 'number').value, '') self.assertEqual(Attribute([], 'list').type, 'text') self.assertEqual(Attribute([], 'text').value, '')
def test_get_data_type_handles_empty_data(self): assert Attribute('', 'text').type == 'text' assert Attribute('', 'text').value == '' assert Attribute(None, 'number').type == 'text' assert Attribute(None, 'number').value == '' assert Attribute([], 'list').type == 'text' assert Attribute([], 'text').value == ''
def test_a_optional_attribute_with_a_value(self): attribute = Attribute('Managed email service', 'text', optional=True) self.assertEqual(attribute.answer_required, False)
def test_get_data_value_retrieves_correct_value(self): self.assertEqual( Attribute('24/7, 365 days a year', 'text').value, '24/7, 365 days a year')
def test_a_optional_attribute_with_no_value(self): attribute = Attribute('', 'text', optional=True) self.assertEqual(attribute.answer_required, False)
def test_get_data_value_retrieves_correct_value(self): assert Attribute('24/7, 365 days a year', 'text').value == '24/7, 365 days a year'