def test_label_list_tojson(self): burndown = Burndown("test burndown") story_xml = ET.parse("data/story_1").getroot() story = Story(xml_to_dictonary(story_xml)) burndown = addState(burndown, [story]) labels = burndown_labels(burndown) self.assertEqual(labels_tojson(labels ), json.dumps(['all','epic_name']))
def test_generate_list_labels(self): burndown = Burndown("test burndown") story_xml = ET.parse("data/story_1").getroot() story = Story(xml_to_dictonary(story_xml)) burndown = addState(burndown, [story]) burndown = addState(burndown, [story]) self.assertEqual(burndown_labels(burndown),['all','epic_name'])
def StoryList(story_xml_list): converter = lambda proj_xml: Story(xml_to_dictonary(proj_xml)) nested_story_list = map(lambda stories_xml: convert_elements(converter, stories_xml, 'story'), story_xml_list) #fastest way to flatten array of arrays story_list = [story for stories in nested_story_list for story in stories] return story_list
def test_story_construct_from_xml(self): xml_string = ''' <story> <name>All The Things</name> <id>3333333</id> <updated_at>2012/09/20 14:10:53 UTC</updated_at> <extra>this is extra</extra> </story> ''' story_xml = ET.fromstring(xml_string) story_dict = xml_to_dictonary(story_xml) story = Story(story_dict) self.assertEqual(story.name, "All The Things")
def test_construct_project(self): xml_string = ''' <project> <id> 1111111 </id> <name>Test Project</name> <public> false </public> <desciption>There are way more elements than this </desciption> </project> ''' project_xml = ET.fromstring(xml_string) test_project = Project(xml_to_dictonary(project_xml)) self.assertEqual(test_project.name, "Test Project")
def test_UserList_tojson(self): a_user = User("George") story_xml = ET.parse("data/story_2").getroot() story = Story(xml_to_dictonary(story_xml)) a_user.updateWip(story) user_list = [a_user] self.assertEquals( userlist_tojson(user_list), json.dumps([{ "name": "George", "current_stories": [{ "id": "22222222", "name": "The Rest Of the Things", "updated_at":"2012/09/20 14:10:53 UTC", "days_since_updated":_days_since_last_updated(_tracker_string_to_time(story.updated_at), datetime.today()) }], "wip": 1 }], sort_keys=True))
def ProjectList(project_list_xml): converter = lambda proj_xml: Project(xml_to_dictonary(proj_xml)) return convert_elements( converter, project_list_xml, 'project')