Move secrets out to test_pylast.yaml and provide an example.

This commit is contained in:
hugovk 2014-03-01 12:59:07 +02:00
parent 56f3666ced
commit e7153965f0
4 changed files with 23 additions and 4 deletions

1
.gitignore vendored
View file

@ -51,3 +51,4 @@ coverage.xml
# Sphinx documentation
docs/_build/
test_pylast.yaml

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
pyyaml

21
test_pylast.py Normal file → Executable file
View file

@ -5,20 +5,33 @@ Integration (not unit) tests for pylast.py
import datetime
import time
import unittest
import yaml # pip install pyyaml
import pylast
def load_secrets():
with open("test_pylast.yaml", "r") as f: # see test_pylast_example.yaml
doc = yaml.load(f)
print doc
print doc["username"]
return doc
class TestSequenceFunctions(unittest.TestCase):
secrets = None
def unix_timestamp(self):
return int(time.mktime(datetime.datetime.now().timetuple()))
def setUp(self):
self.username = "TODO"
password_hash = "TODO"
if self.__class__.secrets is None:
self.__class__.secrets = load_secrets()
API_KEY = "TODO"
API_SECRET = "TODO"
self.username = self.__class__.secrets["username"]
password_hash = self.__class__.secrets["password_hash"]
API_KEY = self.__class__.secrets["api_key"]
API_SECRET = self.__class__.secrets["api_secret"]
self.network = pylast.LastFMNetwork(api_key = API_KEY, api_secret =
API_SECRET, username = self.username, password_hash = password_hash)

4
test_pylast_example.yaml Normal file
View file

@ -0,0 +1,4 @@
username: TODO_ENTER_YOURS_HERE
password_hash: TODO_ENTER_YOURS_HERE
api_key: TODO_ENTER_YOURS_HERE
api_secret: TODO_ENTER_YOURS_HERE