Completed
Push — master ( 1f636e...cb0f87 )
by Sergio
31s
created

TestCoverpy   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_get_cover_no_results() 0 11 2
A setUp() 0 5 1
A test_get_cover_parse_result() 0 14 1
1
import unittest
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
import coverpy
3
import httpretty
4
import os
5
6
class TestCoverpy(unittest.TestCase):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
7
	def setUp(self):
8
		self.coverpy = coverpy.CoverPy()
9
		# Set up paths...
10
		self.ok_computer = os.path.join(os.path.dirname(__file__), 'mocks/OKComputer.json')
11
		self.empty_response = os.path.join(os.path.dirname(__file__), 'mocks/SuchFakeAlbumPls.json')
12
13
	@httpretty.activate
14
	def test_get_cover_parse_result(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
15
		# OK Computer response
16
		httpretty.register_uri(httpretty.GET, 
17
					"https://itunes.apple.com/search/?limit=1&entity=musicArtist%2CmusicTrack%2Calbum%2Cmix%2Csong&term=OK+Computer&media=music",
18
					body=open(self.ok_computer).read(),
19
					content_type="application/json")
20
21
		# Request the content from the mock
22
		result = self.coverpy.get_cover("OK Computer")
23
24
		# Begin assertions
25
		self.assertEquals(result.name, "OK Computer")
26
		self.assertEquals(result.type, "album")
27
28
	@httpretty.activate
29
	def test_get_cover_no_results(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
30
		# No results response
31
		httpretty.register_uri(httpretty.GET,
32
					"https://itunes.apple.com/search/?limit=1&entity=musicArtist%2CmusicTrack%2Calbum%2Cmix%2Csong&term=Such+Fake+Album+Pls&media=music",
33
					body=open(self.empty_response).read(),
34
					content_type="application/json")
35
36
		# Assert a NoResultsException
37
		with self.assertRaises(coverpy.exceptions.NoResultsException):
38
			self.coverpy.get_cover("Such Fake Album Pls")
39
		
40
if __name__ == '__main__':
41
    unittest.main()