Merged revisions 682-691 via svnmerge from
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 4 Mar 2005 20:54:43 +0000 (20:54 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 4 Mar 2005 20:54:43 +0000 (20:54 +0000)
/kofoto/trunk

1  2 
src/cmdline/kofoto
src/lib/kofoto/search.py
src/lib/kofoto/shelf.py
src/test/searchtests.py
src/test/shelftests.py

Simple merge
@@@ -187,23 -187,16 +187,16 @@@ class AlbumSearchNode
  
      def getQuery(self):
          t = self._album.getType()
-         if t == "allalbums":
-             return "select 1 where null" # Return empty result set.
-         elif t == "allimages":
-             return (" select i.id"
-                     " from   image as i left join attribute as a"
-                     "            on i.id = a.object and a.name = 'captured'"
-                     " order by a.lcvalue, i.directory, i.filename")
-         elif t == "orphans":
+         if t == "orphans":
 -            return (" select imageid"
 -                    " from   image left join attribute"
 -                    " on     imageid = objectid and name = 'captured'"
 -                    " where  imageid not in (select objectid from member)"
 -                    " order by lcvalue, directory, filename")
 +            return (" select i.id"
 +                    " from   image as i left join attribute as a"
 +                    " on     i.id = a.object and a.name = 'captured'"
 +                    " where  i.id not in (select object from member)"
 +                    " order by a.lcvalue, i.directory, i.filename")
          elif t == "plain":
 -            return (" select distinct objectid"
 +            return (" select distinct object"
                      " from   member"
 -                    " where  albumid = %s" % self._album.getId())
 +                    " where  album = %s" % self._album.getId())
          elif t == "search":
              query = self._album.getAttribute(u"query")
              if not query:
Simple merge
Simple merge
@@@ -305,19 -298,16 +301,17 @@@ class TestShelfMethods(TestShelfFixture
      def test_createdObjects(self):
          root = self.shelf.getRootAlbum()
          children = list(root.getChildren())
-         assert len(children) == 6
-         orphans, alpha, beta, gamma, delta, zeta = children
+         assert len(children) == 4
+         orphans, alpha, beta, zeta = children
 -        assert self.shelf.getObject(u"alpha") == alpha
 -        assert self.shelf.getAlbum(u"beta") == beta
 +        assert self.shelf.getAlbum(alpha.getId()) == alpha
 +        assert self.shelf.getAlbumByTag(u"beta") == beta
          assert len(list(alpha.getChildren())) == 11
          assert len(list(beta.getChildren())) == 1
-         assert len(list(gamma.getChildren())) == 8
-         assert len(list(delta.getChildren())) == 11
  
      def test_createdAttributes(self):
 -        image = self.shelf.getImage(
 +        imageversion = self.shelf.getImageVersionByLocation(
              os.path.join(PICDIR, "Canon_Digital_IXUS.jpg"))
 +        image = imageversion.getImage()
          assert image.getAttribute(u"captured") == "2002-02-02 22:20:51"
          assert image.getAttribute(u"cameramake") == "Canon"
          assert image.getAttribute(u"cameramodel") == "Canon DIGITAL IXUS"
  
      def test_getAllAlbums(self):
          albums = list(self.shelf.getAllAlbums())
-         assert len(albums) == 8
+         assert len(albums) == 6
  
 -    def test_getAllImages(self):
 -        images = list(self.shelf.getAllImages())
 -        assert len(images) == 11
 +    def test_getAllImageVersions(self):
 +        imageversions = list(self.shelf.getAllImageVersions())
 +        assert len(imageversions) == 11
  
 -    def test_getImagesInDirectory(self):
 -        images = list(self.shelf.getImagesInDirectory(u"."))
 -        assert len(images) == 0
 -        images = list(self.shelf.getImagesInDirectory(PICDIR))
 -        assert len(images) == 11
 +    def test_getImageVersionsInDirectory(self):
 +        imageversions = list(self.shelf.getImageVersionsInDirectory(u"."))
 +        assert len(imageversions) == 0
 +        imageversions = list(self.shelf.getImageVersionsInDirectory(PICDIR))
 +        assert len(imageversions) == 11
  
      def test_deleteAlbum(self):
 -        self.shelf.deleteAlbum(u"beta")
 +        album = self.shelf.getAlbumByTag(u"beta")
 +        self.shelf.deleteAlbum(album.getId())
  
      def test_negativeRootAlbumDeletion(self):
 +        root = self.shelf.getRootAlbum()
          try:
 -            self.shelf.deleteAlbum(u"root")
 +            self.shelf.deleteAlbum(root.getId())
          except UndeletableAlbumError:
              pass
          else:
@@@ -874,81 -713,21 +868,23 @@@ class TestImageVersion(TestShelfFixture
  
      def test_locationChanged(self):
          location = os.path.join(PICDIR, "arlaharen.png")
 -        image = self.shelf.getImage(location)
 -        image.locationChanged(u"/foo/../bar")
 -        assert image.getLocation() == "/bar"
 +        imageversion = self.shelf.getImageVersionByLocation(location)
 +        imageversion.locationChanged(u"/foo/../bar")
 +        assert imageversion.getLocation() == "/bar"
  
      def test_isAlbum(self):
 -        image = self.shelf.getImage(os.path.join(PICDIR, "arlaharen.png"))
 -        assert not image.isAlbum()
 +        imageversion = self.shelf.getImageVersionByLocation(
 +            os.path.join(PICDIR, "arlaharen.png"))
 +        assert not imageversion.isAlbum()
  
      def test_importExifTags(self):
 -        image = self.shelf.getImage(os.path.join(PICDIR, "arlaharen.png"))
 -        image.importExifTags() # TODO: Test more.
 +        imageversion = self.shelf.getImageVersionByLocation(
 +            os.path.join(PICDIR, "arlaharen.png"))
 +        imageversion.importExifTags() # TODO: Test more.
  
- class TestAllAlbumsAlbum(TestShelfFixture):
-     def test_getType(self):
-         alpha = self.shelf.getAlbumByTag(u"gamma")
-         assert alpha.getType() == "allalbums"
-     def test_isMutable(self):
-         alpha = self.shelf.getAlbumByTag(u"gamma")
-         assert not alpha.isMutable()
-     def test_getChildren(self):
-         gamma = self.shelf.getAlbumByTag(u"gamma")
-         assert len(list(gamma.getChildren())) == 8
-     def test_getAlbumChildren(self):
-         gamma = self.shelf.getAlbumByTag(u"gamma")
-         assert list(gamma.getAlbumChildren()) == list(gamma.getChildren())
-     def test_setChildren(self):
-         gamma = self.shelf.getAlbumByTag(u"gamma")
-         try:
-             gamma.setChildren([])
-         except UnsettableChildrenError:
-             pass
-         else:
-             assert False
-     def test_isAlbum(self):
-         assert self.shelf.getAlbumByTag(u"gamma").isAlbum()
- class TestAllImagesAlbum(TestShelfFixture):
-     def test_getType(self):
-         alpha = self.shelf.getAlbumByTag(u"delta")
-         assert alpha.getType() == "allimages"
-     def test_isMutable(self):
-         alpha = self.shelf.getAlbumByTag(u"delta")
-         assert not alpha.isMutable()
-     def test_getChildren(self):
-         delta = self.shelf.getAlbumByTag(u"delta")
-         assert len(list(delta.getChildren())) == 11
-     def test_getAlbumChildren(self):
-         delta = self.shelf.getAlbumByTag(u"delta")
-         assert list(delta.getAlbumChildren()) == []
-     def test_setChildren(self):
-         delta = self.shelf.getAlbumByTag(u"delta")
-         try:
-             delta.setChildren([])
-         except UnsettableChildrenError:
-             pass
-         else:
-             assert False
-     def test_isAlbum(self):
-         assert self.shelf.getAlbumByTag(u"delta").isAlbum()
  class TestOrphansAlbum(TestShelfFixture):
      def test_getType(self):
 -        orphans = self.shelf.getAlbum(u"orphans")
 +        orphans = self.shelf.getAlbumByTag(u"orphans")
          assert orphans.getType() == "orphans"
  
      def test_isMutable(self):