Skip to content

Commit

Permalink
factories !wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicfit committed Mar 26, 2017
1 parent 9faf474 commit 0d5a748
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
1 change: 1 addition & 0 deletions requirements/requirements.yml
Expand Up @@ -9,6 +9,7 @@ test:
- pytest-cov
- pytest-runner
- nose
- factory_boy

test_py33:
- pathlib
Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
@@ -1,3 +1,4 @@
factory_boy
nose==1.3.7
pytest==3.0.7
pytest-cov==2.4.0
Expand Down
7 changes: 7 additions & 0 deletions src/eyed3/core.py
Expand Up @@ -184,6 +184,13 @@ def track_num(self):
def track_num(self, v):
self._setTrackNum(v)

def __init__(self, title=None, artist=None, album=None, album_artist=None,
track_num=None):
self.title = title
self.artist = artist
self.album = album
self.album_artist = album_artist
self.track_num = track_num

class AudioFile(object):
"""Abstract base class for audio file types (AudioInfo + Tag)"""
Expand Down
4 changes: 2 additions & 2 deletions src/eyed3/id3/tag.py
Expand Up @@ -49,9 +49,9 @@ class TagException(Error):


class Tag(core.Tag):
def __init__(self):
core.Tag.__init__(self)
def __init__(self, **kwargs):
self.clear()
core.Tag.__init__(self, **kwargs)

def clear(self):
'''Reset all tag data.'''
Expand Down
13 changes: 0 additions & 13 deletions src/test/test_core.py
Expand Up @@ -78,19 +78,6 @@ def test_AudioInfo():
assert_true(info.time_secs == 0)
assert_true(info.size_bytes == 0)

def test_Tag():
from eyed3.core import Tag

t = Tag()
# The _set/_get interfaces are there and raise NotImplementedError
for sym in dir(t):
if sym.startswith("_set"):
func = getattr(t, sym)
assert_raises(NotImplementedError, func, "foo")
elif sym.startswith("_get"):
func = getattr(t, sym)
assert_raises(NotImplementedError, func)


def test_Date():
from eyed3.core import Date
Expand Down
22 changes: 22 additions & 0 deletions src/test/test_factory.py
@@ -0,0 +1,22 @@
import eyed3.id3
import factory


class TagFactory(factory.Factory):
class Meta:
model = eyed3.id3.Tag
title = "Track title"
artist = "Artist"
album = "Album"
album_artist = artist
track_num = None


def test_factory():
tag = TagFactory()
assert isinstance(tag, eyed3.id3.Tag)
assert tag.title == "Track title"
assert tag.artist == "Artist"
assert tag.album == "Album"
assert tag.album_artist == tag.artist
assert tag.track_num == (None, None)

0 comments on commit 0d5a748

Please sign in to comment.