Example #1
0
	def test_it_should_extract_fields_from_child_nodes(self):
		parent = self.__add_node(self.root, 'This is the front', {'anki:field' : 'Front'})
		child = self.__add_node(parent, 'This is the back', {'anki:field' : 'Back'})
		fp_node = Node(self.root, parent)
		fields = fp_node.get_fields()

		self.assertEquals('This is the back', fields['Back'])
Example #2
0
	def test_it_should_extract_the_deck_from_the_nearest_ancestor_of_the_node(self):
		node1 = self.__add_node(self.root, 'Root node', {'anki:deck' : 'root_deck'})
		node2 = self.__add_node(node1, 'Blah', {'anki:deck' : 'parent_deck'})
		node3 = self.__add_node(node2, 'Blah')
		fp_node = Node(self.root, node3)
		
		self.assertEqual('parent_deck', fp_node.get_deck())
Example #3
0
	def test_it_should_extract_fields_from_nested_child_nodes(self):
		parent = self.__add_node(self.root, 'This is the front', {'anki:field' : 'Front'})
		middle = self.__add_node(parent, 'This does not define a field, but it has a child that does')
		child = self.__add_node(middle, 'This is the back', {'anki:field' : 'Back'})
		fp_node = Node(self.root, parent)
		fields = fp_node.get_fields()

		self.assertEquals('This is the back', fields['Back'])
Example #4
0
	def test_it_should_extract_the_field_from_the_anki_field_attribute(self):
		text = 'This is the node text'
		node = self.__add_node(self.root, text, {'anki:field' : 'Name'})
		fp_node = Node(self.root, node)
		
		fields = fp_node.get_fields()
		self.assertTrue(fields.has_key('Name'), "Expected field list to contain a 'Name' key")
		self.assertEquals(text, fields['Name'])
Example #5
0
    def test_it_should_replace_the_wildcard_character_with_the_node_text(self):
        node = self.__add_node(self.root, {'anki:field:Foo': 'Bar * Baz'},
                               'Foo')
        fp_node = Node(self.root, node)

        fields = fp_node.get_fields()
        self.assertTrue('Foo' in fields,
                        "Expected field list to contain a 'Foo' key")
        self.assertEqual('Bar Foo Baz', fields['Foo'])
Example #6
0
    def test_it_should_extract_fields_from_the_anki_field_wildcard_attribute(
            self):
        node = self.__add_node(self.root, {'anki:field:Bar': 'Baz'})
        fp_node = Node(self.root, node)

        fields = fp_node.get_fields()
        self.assertTrue('Bar' in fields,
                        "Expected field list to contain a 'Bar' key")
        self.assertEqual('Baz', fields['Bar'])
Example #7
0
    def test_it_should_not_extract_fields_from_sub_notes(self):
        parent = self.__add_node(self.root)
        sub_note = self.__add_node(parent, {'anki:model': 'Basic'})
        self.__add_node(sub_note,
                        {'anki:field:SubNote': 'This should be ignored'})

        fp_node = Node(self.root, parent)
        fields = fp_node.get_fields()

        self.assertFalse('SubNote' in fields)
Example #8
0
	def test_it_should_not_extract_fields_from_sub_notes(self):
		parent = self.__add_node(self.root, 'This is the parent node')
		sub_note = self.__add_node(parent, 'This is another note', {'anki:model' : 'Basic'})
		sub_note_field = self.__add_node(sub_note, 'This is a field in the sub note which should be ignored', {'anki:field' : 'SubNote'})

		fp_node = Node(self.root, parent)
		fields = fp_node.get_fields()

		self.assertFalse(fields.has_key('SubNote'))

		
Example #9
0
    def test_it_should_extract_fields_from_nested_child_nodes(self):
        parent = self.__add_node(self.root,
                                 {'anki:field:Front': 'This is the front'})

        middle = self.__add_node(parent)
        self.__add_node(middle, {'anki:field:Back': 'This is the back'})

        fp_node = Node(self.root, parent)
        fields = fp_node.get_fields()

        self.assertEqual('This is the back', fields['Back'])
Example #10
0
	def test_it_should_extract_the_node_text(self):
		text = 'This is the node text'
		node = self.__add_node(self.root, text, {'anki:field' : 'Name'})
		fp_node = Node(self.root, node)
		self.assertEquals(text, fp_node.get_text())
Example #11
0
	def test_it_should_extract_the_id_from_the_node(self):
		node = self.__add_node(self.root, 'Root node', {'anki:model' : 'Basic'})
		fp_node = Node(self.root, node)
		
		self.assertEqual('ID_1', fp_node.get_node_id())
Example #12
0
	def test_it_should_extract_the_model_from_the_anki_model_attribute(self):
		node = self.__add_node(self.root, 'Root node', {'anki:model' : 'Basic'})
		fp_node = Node(self.root, node)
		
		self.assertEqual('Basic', fp_node.get_model())