mirror of
https://github.com/beetbox/beets.git
synced 2025-12-29 20:12:33 +01:00
Added a very basic test_library.py
test_library.py so far just documents existing behavior of album objects, especially the fact that trying to access unset fields causes an AttributeError.
This commit is contained in:
parent
95a456acfc
commit
d9554746cd
1 changed files with 45 additions and 0 deletions
45
test/test_library.py
Normal file
45
test/test_library.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# 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')
|
||||
|
||||
Loading…
Reference in a new issue