diff --git a/test/test_db.py b/test/test_db.py index 75a31ecb8..aa8bd0c8f 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -508,6 +508,15 @@ class AlbumInfoTest(unittest.TestCase): c = self.lib.conn.execute('SELECT id FROM items WHERE id=?', (item_id,)) self.assertEqual(c.fetchone(), None) +class BaseAlbumTest(unittest.TestCase): + def test_field_access(self): + album = beets.library.BaseAlbum(None, {'fld1':'foo'}) + self.assertEqual(album.fld1, 'foo') + + def test_field_access_unset_values(self): + album = beets.library.BaseAlbum(None, {}) + self.assertRaises(AttributeError, getattr, album, 'field') + class ArtDestinationTest(unittest.TestCase): def setUp(self): self.lib = beets.library.Library(':memory:') diff --git a/test/test_library.py b/test/test_library.py deleted file mode 100644 index 9b1243db7..000000000 --- a/test/test_library.py +++ /dev/null @@ -1,45 +0,0 @@ -# This file is part of beets. -# Copyright 2010, Adrian Sampson. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -"""Basic tests for the objects that are used to represent the beets -library and the items in it. -""" - -import unittest -import sys -sys.path.append('..') -from beets.library import BaseLibrary, BaseAlbum - -class AlbumTest(unittest.TestCase): - - def test_field_access(self): - album = BaseAlbum(None, {'artist':'foo', 'albumartist':'bar'}) - self.assertEqual(album.artist, 'foo') - self.assertEqual(album.albumartist, 'bar') - - def test_field_access_unset_values(self): - """ - This is how things work currently. Trying to access unset album - metadata raises an AttributeError. - """ - album = BaseAlbum(None, {}) - self.assertRaises(AttributeError, getattr, album, 'albumartist') - self.assertRaises(AttributeError, getattr, album, 'artist') - -def suite(): - return unittest.TestLoader().loadTestsFromName(__name__) - -if __name__ == '__main__': - unittest.main(defaultTest='suite') -