コード例 #1
0
ファイル: modeltest.py プロジェクト: cazino/Ingestion
 def setUp(self):
     self.path = TEST_COMMON  + '/batch1/3596971288129'
     self.idol_delivery = IDOLDelivery(self.path)
     self._init_expected_data()
コード例 #2
0
ファイル: modeltest.py プロジェクト: cazino/Ingestion
class TestIDOLDelivery1(TestCase):
        
    def setUp(self):
        self.path = TEST_COMMON  + '/batch1/3596971288129'
        self.idol_delivery = IDOLDelivery(self.path)
        self._init_expected_data()

    def _init_expected_data(self):
        artist = DeliveryArtist(pk=12, name='Wax Tailor')
        label = DeliveryLabel(pk=103, name=u"Atmosphériques")
        territories = tuple(['AD', 'BE', 'CH', 'FR', 'GP', 'GY', 'LU', 'MC', 'MQ', 'NC', 'NL', 'PF', 'PM', 'RE', 'YT'])
        release = DeliveryRelease(pk=911, title='Hope & Sorrow', territories=territories,
                                  upc=3596971288129, publish_date=datetime.strptime('2007-04-02', '%Y-%m-%d').date(),
                                  publish_date_digital=datetime.strptime('2007-04-02', '%Y-%m-%d').date(), price=u'B0',
                                  compil=False)
        release.label = label
        release.artist = artist
        artist.release = release
        label.release = release
        self.expected_release = release
        self.expected_artist = artist
        self.expected_label = label
        

    def test_path(self):
        self.assertEqual(self.path, self.idol_delivery.path)
            
    def test_release(self):
        self.assertEqual(self.expected_release, self.idol_delivery.release)
        
    def test_artist(self):
        self.assertEqual(self.expected_artist, self.idol_delivery.artist)
    
    def test_image(self):
        ima_name = '3596971288129.jpg'
        expected_image = DeliveryImage(format='jpg', name=ima_name, 
                                       path=os.path.join(self.idol_delivery.path, ima_name))
        self.assertEqual(expected_image, self.idol_delivery.image)
        
    def test_label(self):
        self.assertEqual(self.expected_label, self.idol_delivery.label)

    def test_styles(self):
        expected_styles = [DeliveryStyle(name="Black Music : Hip Hop"), 
                           DeliveryStyle(name="Electronique : Electro Hip Hop, Abstract Hip Hop...")]
        self.assertEquals(self.idol_delivery.styles, expected_styles)
                                                                                  
    def test_track_1(self):
        expected_track = DeliveryTrack(pk=10934, title='Once upon a past', isrc='FR2DK0680010', 
                                       disc_number=1, track_number=1, price='S10', bundle_only=False,
                                       composer='Jean Christophe Le Saout',
                                       author='Nate Harrison')
        produced_track = self.idol_delivery.tracks[0]
        produced_track.audio_files = None
        self.assertEqual(expected_track, produced_track)

    def test_track_2(self):
        expected_track = DeliveryTrack(pk=10935, title='The way we lived (feat. Sharon Jones)', 
                                       isrc='FR2DK0680020', 
                                       disc_number=1, track_number=2, price='S10', bundle_only=False,
                                       composer='Jean Christophe Le Saout',
                                       author='Charlotte Savary')
        produced_track = self.idol_delivery.tracks[1]
        produced_track.audio_files = None
        self.assertEqual(expected_track, produced_track)
    
    def test_audio_file_master(self):
        self.assertEqual(None, (self.idol_delivery.tracks[0].audio_files['master']))            
            
    def test_track_numer(self):
        self.assertEqual(15, len(self.idol_delivery.tracks))
        
    def test_get_track(self):
        expected_track = DeliveryTrack(pk=10934, title='Once upon a past', isrc='FR2DK0680010', 
                                       disc_number=1, track_number=1, price='S10', bundle_only=False,
                                       author='Nate Harrison', composer='Jean Christophe Le Saout')
        produced_track = self.idol_delivery.get_track(pk=10934)
        produced_track.audio_files = None
        self.assertEqual(expected_track, produced_track)
                
    def _audiofile_1(self):
        name = 'FR2DK0680010.mp3'
        return DeliveryAudioFile(format='mp3', bitrate=320, name=name, 
                                                content='piste', duration=287, size=8149497, path=self.path+'/'+name)
    
    def _audiofile_2(self):
        name = 'FR2DK0680010_preview.mp3'
        return DeliveryAudioFile(format='mp3', bitrate=320, name=name,
                                                content='extrait', duration=30, size=2077313, path=self.path+'/'+name)
    
    def test_audio_file_normal(self):
        expected_audio_file = self._audiofile_1()
        self.assertEqual(expected_audio_file, (self.idol_delivery.tracks[0].audio_files['normal']))
        
    def test_audio_file_sample(self):
        expected_audio_file = self._audiofile_2()
        self.assertEqual(expected_audio_file, (self.idol_delivery.tracks[0].audio_files['sample']))
        
    def test_audiofile_list(self):
        produced_audiofiles = self.idol_delivery.audiofiles()
        self.assertTrue(self._audiofile_1() in produced_audiofiles)
        self.assertTrue(self._audiofile_2() in produced_audiofiles)
        
    def test_good_equality(self):
        delivery1 = self.idol_delivery
        delivery2 = self.idol_delivery
        self.assertEqual(delivery1, delivery2)

    def test_false_equality(self):
        delivery1 = self.idol_delivery
        delivery2 = IDOLDelivery(TEST_COMMON  + '/batch2/3300450000368')
        self.assertNotEqual(delivery1, delivery2)
        
    def test_hash_stability(self):
        delivery1 = self.idol_delivery
        self.assertEqual(hash(delivery1), hash(delivery1))
        
    def test_hash_equality(self):
        delivery1 = self.idol_delivery
        delivery2 = self.idol_delivery
        self.assertEqual(hash(delivery1), hash(delivery2))

    def test_equality_with_deep_copy_delivery(self):
        delivery1 = self.idol_delivery
        delivery2 = copy.deepcopy(delivery1)
        self.assertEqual(delivery1, delivery2)