|  | @@ -24,19 +24,20 @@ class TestDB:
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |      def test_find_tag(self):
 |  |      def test_find_tag(self):
 | 
												
													
														
															|  |          tag_name = 'food'
 |  |          tag_name = 'food'
 | 
												
													
														
															|  | -        t = m.Tag.find_tag(tag_name)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        u = m.User.create(name='gdritter')
 | 
												
													
														
															|  | 
 |  | +        t = m.Tag.find_tag(u, tag_name)
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          # we should be able to find the tag with the given name
 |  |          # we should be able to find the tag with the given name
 | 
												
													
														
															|  | -        named_tags = m.Tag.select(m.Tag.name == tag_name)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        named_tags = m.Tag.select(m.Tag.user == u and m.Tag.name == tag_name)
 | 
												
													
														
															|  |          assert len(named_tags) == 1
 |  |          assert len(named_tags) == 1
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          # subsequent calls to find_tag should return the same db row
 |  |          # subsequent calls to find_tag should return the same db row
 | 
												
													
														
															|  | -        t2 = m.Tag.find_tag(tag_name)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        t2 = m.Tag.find_tag(u, tag_name)
 | 
												
													
														
															|  |          assert t.id == t2.id
 |  |          assert t.id == t2.id
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |      def test_find_hierarchy(self):
 |  |      def test_find_hierarchy(self):
 | 
												
													
														
															|  | -        tag_name = 'food/bread/rye'
 |  | 
 | 
												
													
														
															|  | -        t = m.Tag.find_tag(tag_name)
 |  | 
 | 
												
													
														
															|  | 
 |  | +        u = m.User.create(name='gdritter')
 | 
												
													
														
															|  | 
 |  | +        t = m.Tag.find_tag(u, 'food/bread/rye')
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          # this should have created three DB rows: for 'food', for
 |  |          # this should have created three DB rows: for 'food', for
 | 
												
													
														
															|  |          # 'food/bread', and for 'food/bread/rye':
 |  |          # 'food/bread', and for 'food/bread/rye':
 | 
												
											
												
													
														
															|  | @@ -49,7 +50,9 @@ class TestDB:
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |          # creating a new hierarchical tag with a shared prefix should
 |  |          # creating a new hierarchical tag with a shared prefix should
 | 
												
													
														
															|  |          # only create the new child tag
 |  |          # only create the new child tag
 | 
												
													
														
															|  | -        t2 = m.Tag.find_tag('food/bread/baguette')
 |  | 
 | 
												
													
														
															|  | 
 |  | +        t2 = m.Tag.find_tag(u, 'food/bread/baguette')
 | 
												
													
														
															|  | 
 |  | +        print([t.name for t in m.Tag.select()])
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |          assert len(m.Tag.select()) == 4
 |  |          assert len(m.Tag.select()) == 4
 | 
												
													
														
															|  |          # it should share the same parent tags
 |  |          # it should share the same parent tags
 | 
												
													
														
															|  |          assert t2.parent.id == t.parent.id
 |  |          assert t2.parent.id == t.parent.id
 |