def test_get_data_type_recognises_dictionaries(self): attribute = Attribute('supportAvailability', self.fixture) dictionary = { "assurance": "Service provider assertion", "value": True } self.assertEqual(attribute.get_data_type(dictionary), 'dictionary')
def test_get_data_type_recognises_functions(self): attribute = Attribute('supportAvailability', self.fixture) def _func(): pass self.assertEqual( attribute.get_data_type(_func), 'function' )
def test_is_empty_certifications_field_works_with_full_list(self): self.fixture['vendorCertifications'] = ['Not applicable'] attribute = Attribute('vendorCertifications', self.fixture) self.assertEqual(attribute.is_empty_certifications_field(), False)
def test_is_empty_certifications_field_works_with_empty_list(self): self.fixture['vendorCertifications'] = [] attribute = Attribute('vendorCertifications', self.fixture) self.assertEqual(attribute.is_empty_certifications_field(), True)
def test_format_returns_the_first_item_for_a_list_with_one_item(self): self.fixture['supportedDevices'] = ['PC'] attribute = Attribute('supportedDevices', self.fixture) self.assertEqual(attribute.format(["PC"]), "PC")
def test_format_returns_empty_string_for_a_empty_list(self): self.fixture['supportedDevices'] = [] attribute = Attribute('supportedDevices', self.fixture) self.assertEqual(attribute.format([]), "")
def test_format_returns_no_for_true_boolean(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual(attribute.format(False), 'No')
def test_format_returns_yes_for_true_boolean(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual(attribute.format(True), 'Yes')
def test_get_data_type_returns_false_for_unrecognised_type(self): attribute = Attribute('supportAvailability', self.fixture) self.assertFalse(attribute.get_data_type(('name', 'address')))
def test_get_data_type_recognises_booleans(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual( attribute.get_data_type(True), 'boolean' )
def test_get_data_type_recognises_lists(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual( attribute.get_data_type([1, 2]), 'list' )
def test_get_data_type_recognises_unicode_strings(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual( attribute.get_data_type(u'24x7x365 with UK based engineers'), 'string' )
def test_get_data_type_recognises_integer(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual( attribute.get_data_type(99), 'integer' )
def test_get_data_type_recognises_floats(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual( attribute.get_data_type(99.99), 'float' )
def test_get_data_value_retrieves_correct_value(self): attribute = Attribute('supportAvailability', self.fixture) self.assertEqual( attribute.get_data_value(), '24/7, 365 days a year' )