Nosetests and scripting coverage

I am trying to run nosetests and coverage to see that my tests work correctly in a group project. When I run, although the coverage is still at 0%, and I wonder why. I tried changing the test class to TestSteam as this will help, but it doesn't seem to work:

Script code (hackathon / scripts / steam.py):

def gamespulling(steamID,key): # Returns the XML data from the Steam API based of one Steam ID number and returns a dictionary of gameids and minutes played. steaminfo = {'key': key, 'steamid': steamID,'format':'JSON','include_appinfo':'1'} r = requests.get('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/',params=steaminfo) d = json.loads(r.content) # print d['response']['games'] # print r.json() return d['response']['games'] def steamIDpulling(SteamUN,key): #Pulls out and returns the steam id number for use in steam queries. steaminfo = {'key': key,'vanityurl': SteamUN} a = requests.get('http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/',params=steaminfo) k = json.loads(a.content) SteamID = k['response']['steamid'] print SteamID return SteamID # steampulling(steamID) steamID = steamIDpulling(SteamUN, key) gamespulling(steamID,key) 

Test code:

 def testGetUserIDNum(self): '''Test for steam.py method''' # Pulling from setUp userID = self.userID API_URL = self.API_URL APIKEY = self.APIKEY # constructing the URL self.url = API_URL + '?' + APIKEY + '&' + userID with patch("requests.get") as mock_requests_get: mock_requests_get.return_value = """{"response": {"streamid":76561197997115778}}""" self.assertEqual(steamIDPulling(userID,APIKEY), 76561197997115778) def testgamespulling(self): '''Test gamesPulling method''' # Using test account due to huge JSON from normal one. steamnum = self.steamnum with patch("requests.get") as mock_requests_get: jsonList = [{"response": {"game_count": 0}}] self.assertEqual(gamesPulling(steamnum,APIKEY),jsonList) 

I get:

 Name Stmts Miss Cover Missing -------------------------------------------------------------------- hackathon/__init__.py 0 0 100% hackathon/admin.py 3 3 0% 1-5 hackathon/forms.py 9 9 0% 1-11 hackathon/migrations/0001_initial.py 6 0 100% hackathon/migrations/__init__.py 0 0 100% hackathon/models.py 6 6 0% 1-11 hackathon/scripts/__init__.py 0 0 100% hackathon/scripts/github.py 106 96 9% 17-34, 41-64, 69-97, 102-121, 126-132, 139-165, 169-175 hackathon/scripts/linkedin.py 19 19 0% 1-24 hackathon/scripts/samplescript.py NoSource: No source for code: '/Users/DrkSephy/Documents/django-hackathon-starter/hackathon_starter/hackathon/scripts/samplescript.py'. hackathon/scripts/steam.py 15 15 0% 3-29 hackathon/scripts/tumblr.py 60 60 0% 1-85 hackathon/tests.py 1 0 100% hackathon/urls.py 3 3 0% 1-5 hackathon/views.py 76 76 0% 1-157 -------------------------------------------------------------------- TOTAL 304 287 6% ---------------------------------------------------------------------- Ran 2 tests in 0.002s OK Destroying test database for alias 'default'... 
0
source share

All Articles