def test_DictShouldProduceExpectedXML(self): pairs = [ ({ 'a': None }, '<?xml version="1.0" encoding="UTF-8"?>\n<a />'), ({ 'a': 5 }, '<?xml version="1.0" encoding="UTF-8"?>\n<a>5</a>'), ({ 'a': 'x' }, '<?xml version="1.0" encoding="UTF-8"?>\n<a><![CDATA[x]]></a>'), ({ 'a': { 'b': [{ 'c': 5 }, 6, 'x', None], 'd': 7 } }, '<?xml version="1.0" encoding="UTF-8"?>\n<a><b><c>5</c></b><b>6</b><b><![CDATA[x]]></b><b /><d>7</d></a>' ), ] for d, x in pairs: self.assertEqual(x2d.dict2xml(d), x)
def create_project(self, **kwds): """Write a new project to LikeMinded. Keyword arguments: name -- status -- start_date -- end_date -- problem -- process -- result -- external_feed_account_type -- external_feed_account -- locationslink -- resources -- categories -- Return a ProjectDetails object representing the newly created data. """ project_xml = dict2xml({'project':kwds}) path = '/projects' query = { 'apikey' : self.__key } body = project_xml response, project_xml = self.__connection.post(path, query, project_xml) print project_xml return self.__read_details_helper(project_xml, 'project', ProjectDetails)
def create_resource(self, **kwds): """Write a new resource to LikeMinded. Keyword arguments: name -- description -- url -- created -- updated -- author -- link -- locations -- projects -- categories -- Return a ResourceDetails object representing the newly created data. """ resource_xml = dict2xml({'resource':kwds}) path = '/resources' query = { 'apikey' : self.__key } body = resource_xml response, resource_xml = self.__connection.post(path, query, resource_xml) return self.__read_details_helper(resource_xml, 'resource', ResourceDetails)
def test_DictShouldProduceExpectedXML(self): pairs = [ ({'a' : None}, '<?xml version="1.0" encoding="UTF-8"?>\n<a />'), ({'a' : 5}, '<?xml version="1.0" encoding="UTF-8"?>\n<a>5</a>'), ({'a' : 'x'}, '<?xml version="1.0" encoding="UTF-8"?>\n<a><![CDATA[x]]></a>'), ({'a' : {'b' : [{'c' : 5}, 6, 'x', None], 'd' : 7}}, '<?xml version="1.0" encoding="UTF-8"?>\n<a><b><c>5</c></b><b>6</b><b><![CDATA[x]]></b><b /><d>7</d></a>'), ] for d, x in pairs: self.assertEqual(x2d.dict2xml(d), x)