source: products/Plone4ArtistsAudioPatch/trunk/extralibs/p4a.audiopatch/p4a/audiopatch/plone-audio-impl.txt

Last change on this file was 1, checked in by myroslav, 18 years ago

Building directory structure

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1Plone Audio Patch
2=================
3
4The following doctest suite is meant to be run against mp3 audio implementation
5to ensure that p4a.audiopatch added to p4a.audio support for correct reading not
6english id3 tag info. (This doctest suite borrows much from Plone4ArtistsAudio testsuite.)
7
8We begin this process by creating a new instance of a file content
9type.
10
11  >>> id = self.folder.invokeFactory(self.file_content_type, 'samplefile')
12  >>> samplefile = self.folder[id]
13
14Keeping the sample audio files small it should be no problem loading
15them into memory for testing purposes.  So we proceed to give the
16previous file instance the sample file binary data.
17
18  >>> f = open(self.samplefile, 'rb')
19  >>> data = f.read()
20  >>> f.close()
21  >>> samplefile.getRawFile().update_data(data, self.required_mimetype, len(data))
22
23This is all fine and dandy but since we went a little lowlevel to update
24the file, this means IAudio hasn't had a chance to update the audio
25metadata and related logic.  So we need to fire IObjectModifiedEvent to
26kick IAudio.
27
28  >>> from zope import event
29  >>> from zope.app.event import objectevent
30  >>> event.notify(objectevent.ObjectModifiedEvent(samplefile))
31
32Now lets look up IAudio and get the data we expect from importing the
33audio file.
34 
35  >>> from p4a.audio.interfaces import IAudio
36  >>> audiofile = IAudio(samplefile)
37
38Lets check does audiofile provide IAudioEncoded interface (added by Plone4artistsAudioPatch)
39
40  >>> from p4a.audiopatch.interfaces import IAudioEncoded
41  >>> IAudioEncoded.providedBy(audiofile)
42  True
43  >>> audiofile.encoding == ''
44  True
45  >>> audiofile.original_encoding == self.eyeD3_encoding
46  True
47
48Lets check that audiofile info fields are encoded wrong
49
50  >>> audiofile.title == self.fields['title']
51  False
52  >>> audiofile.album == self.fields['album']
53  False
54  >>> audiofile.artist == self.fields['artist']
55  False
56
57Now we set right encoding of id3 tag.
58
59  >>> audiofile.encoding = self.tag_encoding
60  >>> audiofile.title == self.fields['title']
61  True
62  >>> audiofile.album == self.fields['album']
63  True
64  >>> audiofile.artist == self.fields['artist']
65  True
66
67Do a little CMF testing.
68
69  >>> samplefile.Title() == self.fields['title'].encode('utf-8')
70  True
71
72Test reset of encodings fields when IObjectModifiedEvent fired.
73
74  >>> event.notify(objectevent.ObjectModifiedEvent(samplefile))
75  >>> audiofile.encoding
76  ''
77  >>> audiofile.original_encoding
78  'utf_8'
79
80
Note: See TracBrowser for help on using the repository browser.