Move secrets out to test_pylast.yaml and provide an example.
This commit is contained in:
parent
56f3666ced
commit
e7153965f0
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -51,3 +51,4 @@ coverage.xml
|
||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|
||||||
|
test_pylast.yaml
|
||||||
|
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pyyaml
|
21
test_pylast.py
Normal file → Executable file
21
test_pylast.py
Normal file → Executable file
|
@ -5,20 +5,33 @@ Integration (not unit) tests for pylast.py
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
import yaml # pip install pyyaml
|
||||||
|
|
||||||
import pylast
|
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):
|
class TestSequenceFunctions(unittest.TestCase):
|
||||||
|
|
||||||
|
secrets = None
|
||||||
|
|
||||||
def unix_timestamp(self):
|
def unix_timestamp(self):
|
||||||
return int(time.mktime(datetime.datetime.now().timetuple()))
|
return int(time.mktime(datetime.datetime.now().timetuple()))
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.username = "TODO"
|
if self.__class__.secrets is None:
|
||||||
password_hash = "TODO"
|
self.__class__.secrets = load_secrets()
|
||||||
|
|
||||||
API_KEY = "TODO"
|
self.username = self.__class__.secrets["username"]
|
||||||
API_SECRET = "TODO"
|
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 =
|
self.network = pylast.LastFMNetwork(api_key = API_KEY, api_secret =
|
||||||
API_SECRET, username = self.username, password_hash = password_hash)
|
API_SECRET, username = self.username, password_hash = password_hash)
|
||||||
|
|
4
test_pylast_example.yaml
Normal file
4
test_pylast_example.yaml
Normal 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
|
Loading…
Reference in a new issue