Example #1
0
    def test_regroup_data_file_tags_sort_desc(self):
        self._init_test_data_file()
        title1 = 'title 1'
        title2 = 'title 2'
        title3 = 'title 3'
        title4 = 'title 4'
        tag1 = 'tag 1'
        tag2 = 'tag 2'
        tag3 = 'tag 3'
        tag4 = 'tag 4'
        tags1 = [tag1, tag2]
        tags2 = [tag3, tag4]
        item1 = Item(title1, {Elem.TAGS : tags1})
        item2 = Item(title2, {Elem.TAGS : tags2})
        item3 = Item(title3, {Elem.TAGS : tags1})
        item4 = Item(title4, {Elem.TAGS : tags2})
        orgm = Organizem(TEST_DATA_FILE, IS_UNIT_TESTING)
        orgm.add_item(item1)
        orgm.add_item(item2)
        orgm.add_item(item3)
        orgm.add_item(item4)

        grouped_items = orgm.get_grouped_items(Elem.TAGS)
        new_data_file_str = orgm.regroup_data_file(Elem.TAGS, ActionArg.DESCENDING, with_group_labels=False)
        grouped_items_str = []
        group_keys = grouped_items.keys()
        group_keys.reverse()
        for group_key in group_keys:          
            for item in grouped_items[group_key]:
                grouped_items_str.append(str(item))
        grouped_items_str = "\n".join(grouped_items_str)
        self.assertTrue(grouped_items_str == new_data_file_str)
Example #2
0
    def test_regroup_data_file_area(self):
        self._init_test_data_file()
        title1 = 'title 1'
        title2 = 'title 2'
        title3 = 'title 3'
        title4 = 'title 4'
        area1 = 'area 1'
        area2 = 'area 2'
        item1 = Item(title1, {Elem.AREA : area1})
        item2 = Item(title2, {Elem.AREA : area2})
        item3 = Item(title3, {Elem.AREA : area1})
        item4 = Item(title4, {Elem.AREA : area2})
        orgm = Organizem(TEST_DATA_FILE, IS_UNIT_TESTING)
        orgm.add_item(item1)
        orgm.add_item(item2)
        orgm.add_item(item3)
        orgm.add_item(item4)

        grouped_items = orgm.get_grouped_items(Elem.AREA)
        new_data_file_str = orgm.regroup_data_file(Elem.AREA, ActionArg.ASCENDING, with_group_labels=False)
        grouped_items_str = []
        for group_key in grouped_items.keys():          
            for item in grouped_items[group_key]:
                grouped_items_str.append(str(item))
        grouped_items_str = "\n".join(grouped_items_str)
        self.assertTrue(grouped_items_str == new_data_file_str)
Example #3
0
    def test_get_grouped_items_tags(self):
        self._init_test_data_file()
        title1 = 'title 1'
        title2 = 'title 2'
        title3 = 'title 3'
        title4 = 'title 4'
        tag1 = 'tag 1'
        tag2 = 'tag 2'
        tag3 = 'tag 3'
        tag4 = 'tag 4'
        tags1 = [tag1, tag2]
        tags2 = [tag3, tag4]
        item1 = Item(title1, {Elem.TAGS : tags1})
        item2 = Item(title2, {Elem.TAGS : tags2})
        item3 = Item(title3, {Elem.TAGS : tags1})
        item4 = Item(title4, {Elem.TAGS : tags2})
        orgm = Organizem(TEST_DATA_FILE, IS_UNIT_TESTING)
        orgm.add_item(item1)
        orgm.add_item(item2)
        orgm.add_item(item3)
        orgm.add_item(item4)

        expected1 = repr([{'item' : [{'title': 'title 1'}, {'area': "''"}, {'project': "''"}, {'tags': [tag1, tag2]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}, \
                     {'item' : [{'title': 'title 3'}, {'area': "''"}, {'project': "''"}, {'tags': [tag1, tag2]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}])
        expected2 = repr([{'item' : [{'title': 'title 1'}, {'area': "''"}, {'project': "''"}, {'tags': [tag1, tag2]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}, \
                     {'item' : [{'title': 'title 3'}, {'area': "''"}, {'project': "''"}, {'tags': [tag1, tag2]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}])
        expected3 = repr([{'item' : [{'title': 'title 2'}, {'area': "''"}, {'project': "''"}, {'tags': [tag3, tag4]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}, \
                     {'item' : [{'title': 'title 4'}, {'area': "''"}, {'project': "''"}, {'tags': [tag3, tag4]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}])
        expected4 = repr([{'item' : [{'title': 'title 2'}, {'area': "''"}, {'project': "''"}, {'tags': [tag3, tag4]}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}, \
                     {'item' : [{'title': 'title 4'}, {'area': "''"}, {'project': "''"}, {'tags': [tag3, tag4]}, {'actions': []},{'priority': "''"},  {'due_date': "''"}, {'note': ''}]}])

        actual = orgm.get_grouped_items(Elem.TAGS)
        actual1 = repr(actual[tag1])
        actual2 = repr(actual[tag2])
        actual3 = repr(actual[tag3])
        actual4 = repr(actual[tag4])

        self.assertTrue(expected1 == actual1)
        self.assertTrue(expected2 == actual2)
        self.assertTrue(expected3 == actual3)
        self.assertTrue(expected4 == actual4)
Example #4
0
 def test_get_grouped_items_area(self):
     self._init_test_data_file()
     title1 = 'title 1'
     title2 = 'title 2'
     title3 = 'title 3'
     title4 = 'title 4'
     area1 = 'area 1'
     area2 = 'area 2'
     item1 = Item(title1, {Elem.AREA : area1})
     item2 = Item(title2, {Elem.AREA : area2})
     item3 = Item(title3, {Elem.AREA : area1})
     item4 = Item(title4, {Elem.AREA : area2})
     orgm = Organizem(TEST_DATA_FILE, IS_UNIT_TESTING)
     orgm.add_item(item1)
     orgm.add_item(item2)
     orgm.add_item(item3)
     orgm.add_item(item4)        
     expected1 = repr([{'item' : [{'title': 'title 1'}, {'area': 'area 1'}, {'project': "''"}, {'tags': []}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}, {'item' : [{'title': 'title 3'}, {'area': 'area 1'}, {'project': "''"}, {'tags': []}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}])
     expected2 = repr([{'item' : [{'title': 'title 2'}, {'area': 'area 2'}, {'project': "''"}, {'tags': []}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}, {'item' : [{'title': 'title 4'}, {'area': 'area 2'}, {'project': "''"}, {'tags': []}, {'actions': []}, {'priority': "''"}, {'due_date': "''"}, {'note': ''}]}])
     actual = orgm.get_grouped_items(Elem.AREA)      
     actual1 = repr(actual[area1])
     actual2 = repr(actual[area2])           
     self.assertTrue(expected1 == actual1)
     self.assertTrue(expected2 == actual2)