def testList(self): g = Graph(':memory:') g.set('apple','color','red') # basic comparison operators self.assertEquals(g.list(),['apple','color','red']) self.assertEquals(g.list('color is red'),['apple']) g.set('apple','type','fruit') g.set('banana','type','fruit') self.assertEquals(g.list('color is red and type is fruit'),['apple']) g.set('banana','color','yellow') self.assertEquals(g.list('color is red or color is yellow'),['apple','banana']) self.assertEquals(g.list('color is red or color is yellow and type is fruit'),['apple','banana']) g.set('gmail logo','colors',['red','white']) # this is how it behaves... is this how it should behave? self.assertEquals(g.list('color is red'),['apple','gmail logo']) # temporal g.set('Tim','birthday','6/2/95') g.set('Jim','birthday','10/7/81') self.assertEquals(g.list('birthday is after 1992'),['Tim']) self.assertEquals(g.list('birthday is before 1992'),['Jim']) self.assertEquals(g.list('birthday is after 1992 and birthday is before 2000'),['Tim']) self.assertEquals(g.list('birthday is after 1900'),['Jim','Tim']) # geographical g.set('Barrack Obama','home state','Illinois') g.set('John McCain','home state','Arizona') self.assertEquals(g.list('home state is west of Texas'),['John McCain']) self.assertEquals(g.list('home state is east of Texas'),['Barrack Obama']) self.assertEquals(g.list('home state is north of Mexico'),['Barrack Obama','John McCain']) self.assertEquals(g.list('home state is south of Canada'),['Barrack Obama','John McCain']) g.set('Barrack Obama','hometown','Chicago') self.assertEquals(g.list('hometown is within 50 miles of Gary, Indiana'),['Barrack Obama'])
def testRename(self): g = Graph(':memory:') g.create_page('test page') g.rename('test page','Test Pageee!!!') self.assertEquals(g.list(),['Test Pageee!!!']) self.assertEquals(g.id_cache,{'Test Pageee!!!':1})