Exemple #1
0
    def test_tag_buttons_are_created_when_displaying_a_note(self):
        mockNotesListModel = NotesListModel()

        mockNotesListModel.add_observer = Mock()
        
        view = View(self.__mock_config(), mockNotesListModel)

        note = {
            'content': "title",
            'modifydate': "timestamp",
            'createdate': "timestamp",
            'savedate': 0,  # never been written to disc
            'syncdate': 0,  # never been synced with server
            'tags': ['atag', 'anotherTag']
        }

        view.set_note_data(note)

        tag_elements = view.note_existing_tags_frame.children.values() 

        for element in tag_elements:
            self.assertEqual(element.__class__.__name__, 'Button', "Tag element was not a button")
            self.assertTrue(element['text'] in ['atag x', 'anotherTag x'], "Didn't expect to find a tag with text %s" % element['text'] )
        
        self.assertEqual(len(tag_elements), 2) 
        view.close()
Exemple #2
0
    def test_view_can_check_if_a_notes_content_has_changed(self):
        mockNotesListModel = NotesListModel()
        mockNotesListModel.add_observer = Mock()
        view = View(self.__mock_config(), mockNotesListModel)

        note = {
            'content': "title",
            'modifydate': "timestamp",
            'createdate': "timestamp",
            'savedate': 0,  # never been written to disc
            'syncdate': 0,  # never been synced with server
            'tags': ['atag', 'anotherTag']
        }

        view.set_note_data(note)

        new_note = {
            'content': "new title",
            'modifydate': "timestamp",
            'createdate': "timestamp",
            'savedate': 0,  # never been written to disc
            'syncdate': 0,  # never been synced with server
            'tags': ['atag', 'anotherTag']
        }

        view.set_note_data(note)

        self.assertTrue(view.is_note_different(new_note))

        view.close()
Exemple #3
0
    def test_view_can_check_if_a_notes_content_has_changed(self):
        mockNotesListModel = NotesListModel()
        mockNotesListModel.add_observer = Mock()
        view = View(self.__mock_config(), mockNotesListModel)

        note = {
            'content': "title",
            'modifydate': "timestamp",
            'createdate': "timestamp",
            'savedate': 0,  # never been written to disc
            'syncdate': 0,  # never been synced with server
            'tags': ['atag', 'anotherTag']
        }

        view.set_note_data(note)
        
        new_note = {
            'content': "new title",
            'modifydate': "timestamp",
            'createdate': "timestamp",
            'savedate': 0,  # never been written to disc
            'syncdate': 0,  # never been synced with server
            'tags': ['atag', 'anotherTag']
        }

        view.set_note_data(note)
        
        
        self.assertTrue(view.is_note_different(new_note))

        view.close()
Exemple #4
0
    def test_tag_buttons_are_created_when_displaying_a_note(self):
        mockNotesListModel = NotesListModel()

        mockNotesListModel.add_observer = Mock()

        view = View(self.__mock_config(), mockNotesListModel)

        note = {
            'content': "title",
            'modifydate': "timestamp",
            'createdate': "timestamp",
            'savedate': 0,  # never been written to disc
            'syncdate': 0,  # never been synced with server
            'tags': ['atag', 'anotherTag']
        }

        view.set_note_data(note)

        tag_elements = view.note_existing_tags_frame.children.values()

        for element in tag_elements:
            self.assertEqual(element.__class__.__name__, 'Button',
                             "Tag element was not a button")
            self.assertTrue(
                element['text'] in ['atag x', 'anotherTag x'],
                "Didn't expect to find a tag with text %s" % element['text'])

        self.assertEqual(len(tag_elements), 2)
        view.close()