@@ -18,37 +18,38 @@ def tearDown(self):
18
18
self .unload_plugins ()
19
19
20
20
def test_no_patterns (self ):
21
- i = Item (
22
- comments = 'test comment' ,
23
- day = 13 ,
24
- month = 3 ,
25
- year = 2012 ,
26
- )
21
+ tags = {
22
+ ' comments' : 'test comment' ,
23
+ ' day' : 13 ,
24
+ ' month' : 3 ,
25
+ ' year' : 2012 ,
26
+ }
27
27
z = ZeroPlugin ()
28
28
z .debug = False
29
29
z .fields = ['comments' , 'month' , 'day' ]
30
30
z .patterns = {'comments' : ['.' ],
31
31
'month' : ['.' ],
32
32
'day' : ['.' ]}
33
- z .write_event (i )
34
- self .assertEqual (i . comments , '' )
35
- self .assertEqual (i . day , 0 )
36
- self .assertEqual (i . month , 0 )
37
- self .assertEqual (i . year , 2012 )
33
+ z .write_event (None , None , tags )
34
+ self .assertEqual (tags [ ' comments' ], None )
35
+ self .assertEqual (tags [ ' day' ], None )
36
+ self .assertEqual (tags [ ' month' ], None )
37
+ self .assertEqual (tags [ ' year' ] , 2012 )
38
38
39
39
def test_patterns (self ):
40
- i = Item (
41
- comments = 'from lame collection, ripped by eac' ,
42
- year = 2012 ,
43
- )
44
40
z = ZeroPlugin ()
45
41
z .debug = False
46
42
z .fields = ['comments' , 'year' ]
47
43
z .patterns = {'comments' : 'eac lame' .split (),
48
44
'year' : '2098 2099' .split ()}
49
- z .write_event (i )
50
- self .assertEqual (i .comments , '' )
51
- self .assertEqual (i .year , 2012 )
45
+
46
+ tags = {
47
+ 'comments' : 'from lame collection, ripped by eac' ,
48
+ 'year' : 2012 ,
49
+ }
50
+ z .write_event (None , None , tags )
51
+ self .assertEqual (tags ['comments' ], None )
52
+ self .assertEqual (tags ['year' ], 2012 )
52
53
53
54
def test_delete_replaygain_tag (self ):
54
55
path = self .create_mediafile_fixture ()
@@ -70,6 +71,17 @@ def test_delete_replaygain_tag(self):
70
71
self .assertIsNone (mediafile .rg_track_peak )
71
72
self .assertIsNone (mediafile .rg_track_gain )
72
73
74
+ def test_do_not_change_database (self ):
75
+ item = self .add_item_fixture (year = 2000 )
76
+ mediafile = MediaFile (item .path )
77
+
78
+ config ['zero' ] = {'fields' : ['year' ]}
79
+ self .load_plugins ('zero' )
80
+
81
+ item .write ()
82
+ self .assertEqual (item ['year' ], 2000 )
83
+ self .assertIsNone (mediafile .year )
84
+
73
85
74
86
def suite ():
75
87
return unittest .TestLoader ().loadTestsFromName (__name__ )
0 commit comments