Skip to content

Commit

Permalink
Entry Stub is more strict, to prevent mocks accepting everything
Browse files Browse the repository at this point in the history
  • Loading branch information
pcarranza committed Nov 19, 2014
1 parent 25dbf3a commit 027fce9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GObject(object):
class RB(object):
class RhythmDBPropType(object):
ENTRY_ID = 'entry_id'
ENTRY_ID = 'id'
TITLE = 'title'
ARTIST = 'artist'
ALBUM = 'album'
Expand All @@ -54,7 +54,7 @@ class RB(object):
PLAY_COUNT = 'play_count'
LOCATION = 'location'
BITRATE = 'bitrate'
LAST_PLAYED = 'last_player'
LAST_PLAYED = 'last_played'
ARTIST_FOLDED = 'ARTIST_FOLDED'
TITLE_FOLDED = 'TITLE_FOLDED'
Expand Down
12 changes: 12 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,29 @@ def __str__(self):

class EntryStub(object):

supported_keys = {'id', 'artist', 'album', 'rating',
'track_number', 'title', 'duration',
'year', 'genre', 'play_count', 'bitrate',
'last_played', 'location'}

def __init__(self, key, **kwargs):
self.key = key
self.args = kwargs

def assert_supported(self, name):
if not name in self.supported_keys:
raise AttributeError('{} object as no attribute {}'.format(self, name))

def get_ulong(self, name):
self.assert_supported(name)
return self.args.get(name, self.key)

def get_string(self, name):
self.assert_supported(name)
return self.args.get(name, name)

def get_double(self, name):
self.assert_supported(name)
return self.args.get(name, 1.0)

def __str__(self):
Expand Down

0 comments on commit 027fce9

Please sign in to comment.