def transform(self, data): sets = etree.Element('set') set_spec = etree.SubElement(sets, 'setSpec') set_spec.text = slugfy(data) set_name = etree.SubElement(sets, 'setName') set_name.text = data return sets
def transform(self, item): xml, data = item header = etree.SubElement(xml, 'header') if data.get('deleted'): header.attrib['status'] = 'deleted' identifier = etree.SubElement(header, 'identifier') identifier.text = data.get('identifier') datestamp = etree.SubElement(header, 'datestamp') datestamp.text = data.get('updated') set_spec = etree.SubElement(header, 'setSpec') set_spec.text = slugfy(data.get('publisher', '')) return (xml, data)
def test_slugfy(self): result = slugfy(u'São Paulo Futebol Clube') self.assertEqual(u'sao-paulo-futebol-clube', result)
def test_slugfy_realy_crazy_chars(self): result = slugfy(u' without separators in the begining and end of a string ') self.assertEqual(u'without-separators-in-the-begining-and-end-of-a-string', result)
def test_slugfy_realy_crazy_chars(self): result = slugfy(u'must be empty of crazy chars @çÇ&$%^&*()-_+=¡£¢§¶•–‘“÷≥≤') self.assertEqual(u'must-be-empty-of-crazy-chars-cc', result)
def test_slugfy_differente_separator(self): result = slugfy(u'São Paulo Futebol Clube', separator='#') self.assertEqual(u'sao#paulo#futebol#clube', result)
def test_slugfy_multiple_white_spaces(self): result = slugfy(u'São Paulo Futebol Clube') self.assertEqual(u'sao-paulo-futebol-clube', result)