Beispiel #1
0
	def testConstructor(self):
		s1 = proj1.Song()
		s2 = proj1.Song("Havana", "Camila Cabello", 2018, "https://www.example-url-havana.com", "Camila", "Pop", 216000)

		self.assertEqual(s1.album, "No Album")
		self.assertEqual(s1.track_length, 0)
		self.assertEqual(s2.title, "Havana")
		self.assertEqual(s2.author, "Camila Cabello")
		self.assertEqual(s2.release_year, 2018)
		self.assertEqual(s2.url, "https://www.example-url-havana.com")
		self.assertEqual(s2.album, "Camila")
		self.assertEqual(s2.genre, "Pop")
		self.assertEqual(s2.track_length, 216000)
		self.assertRaises(AttributeError, lambda: s2.rating)
		self.assertRaises(AttributeError, lambda: s2.movie_length)
Beispiel #2
0
	def testSong(self):
		f = open("sample_json.json","r")
		sample_data = json.loads(f.read())
		f.close()
		
		s = proj1.Song(json=sample_data[1])
		
		self.assertEqual(s.title, "Hey Jude")
		self.assertEqual(s.author, "The Beatles")
		self.assertEqual(s.release_year, "1968")
		self.assertEqual(s.url, "https://itunes.apple.com/us/album/hey-jude/400835735?i=400835962&uo=4")
		self.assertEqual(s.album, "TheBeatles 1967-1970 (The Blue Album)")
		self.assertEqual(s.genre, "Rock")
		self.assertEqual(s.track_length, 431333)
		self.assertEqual(s.info(), "Hey Jude by The Beatles (1968) [Rock]")
		self.assertEqual(s.length(), 431)
Beispiel #3
0
    def testLength(self):
        s2 = proj1.Song("Havana", "Camila Cabello", 2018,
                        "https://www.example-url-havana.com", "Camila", "Pop",
                        216000)

        self.assertEqual(s2.length(), 216)
Beispiel #4
0
    def testInfo(self):
        s2 = proj1.Song("Havana", "Camila Cabello", 2018,
                        "https://www.example-url-havana.com", "Camila", "Pop",
                        216000)

        self.assertEqual(s2.info(), "Havana by Camila Cabello (2018) [Pop]")