If no secrets file, load from environment variables. For Travis CI testing.
This commit is contained in:
parent
897d0a132c
commit
baa4e782b6
18
.travis.yml
18
.travis.yml
|
@ -1,10 +1,14 @@
|
|||
language: python
|
||||
python:
|
||||
- "2.6"
|
||||
- "2.7"
|
||||
- "3.2"
|
||||
- "3.3"
|
||||
# command to install dependencies
|
||||
install: "pip install -r requirements.txt"
|
||||
# command to run tests
|
||||
- '2.6'
|
||||
- '2.7'
|
||||
- '3.2'
|
||||
- '3.3'
|
||||
install: pip install -r requirements.txt
|
||||
script: ./test_pylast.py
|
||||
env:
|
||||
matrix:
|
||||
- secure: ivg6II471E9HV8xyqnawLIuP/sZ0J63Y+BC0BQcRVKtLn/K3zmD1ozM3TFL9S549Nxd0FqDKHXJvXsgaTGIDpK8sxE2AMKV5IojyM0iAVuN7YjPK9vwSlRw1u0EysPMFqxOZVQnoDyHrSGIUrP/VMdnhBu6dbUX0FyEkvZshXhY=
|
||||
- secure: gDWNEYA1EUv4G230/KzcTgcmEST0nf2FeW/z/prsoQBu+TWw1rKKSJAJeMLvuI1z4aYqqNYdmqjWyNhhVK3p5wmFP2lxbhaBT1jDsxxFpePc0nUkdAQOOD0yBpbBGkqkjjxU34HjTX2NFNEbcM3izVVE9oQmS5r4oFFNJgdL91c=
|
||||
- secure: RpsZblHFU7a5dnkO/JUgi70RkNJwoUh3jJqVo1oOLjL+lvuAmPXhI8MDk2diUk43X+XCBFBEnm7UCGnjUF+hDnobO4T+VrIFuVJWg3C7iKIT+YWvgG6A+CSeo/P0I0dAeUscTr5z4ylOq3EDx4MFSa8DmoWMmjKTAG1GAeTlY2k=
|
||||
- secure: T5OKyd5Bs0nZbUr+YICbThC5GrFq/kUjX8FokzCv7NWsYaUWIwEmMXXzoYALoB3A+rAglOx6GABaupoNKKg3tFQyxXphuMKpZ8MasMAMFjFW0d7wsgGy0ylhVwrgoKzDbCQ5FKbohC+9ltLs+kKMCQ0L+MI70a/zTfF4/dVWO/o=
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
import yaml # pip install pyyaml
|
||||
|
@ -9,10 +10,19 @@ import yaml # pip install pyyaml
|
|||
import pylast
|
||||
|
||||
def load_secrets():
|
||||
with open("test_pylast.yaml", "r") as f: # see test_pylast_example.yaml
|
||||
secrets_file = "test_pylast.yaml"
|
||||
if os.path.isfile(secrets_file):
|
||||
with open(secrets_file, "r") as f: # see test_pylast_example.yaml
|
||||
doc = yaml.load(f)
|
||||
else:
|
||||
doc = {}
|
||||
doc["username"] = os.environ['PYLAST_USERNAME'].strip()
|
||||
doc["password_hash"] = os.environ['PYLAST_PASSWORD_HASH'].strip()
|
||||
doc["api_key"] = os.environ['PYLAST_API_KEY'].strip()
|
||||
doc["api_secret"] = os.environ['PYLAST_API_SECRET'].strip()
|
||||
return doc
|
||||
|
||||
|
||||
class TestPyLast(unittest.TestCase):
|
||||
|
||||
secrets = None
|
||||
|
@ -56,7 +66,6 @@ class TestPyLast(unittest.TestCase):
|
|||
artist = "Test Artist 2"
|
||||
title = "Test Title 2"
|
||||
timestamp = self.unix_timestamp()
|
||||
print timestamp
|
||||
library = pylast.Library(user = self.username, network = self.network)
|
||||
self.network.scrobble(artist = artist, title = title, timestamp = timestamp)
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
@ -364,7 +373,7 @@ class TestPyLast(unittest.TestCase):
|
|||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# For quick testing of a single-case (eg. test = "test_track_is_hashable"
|
||||
# For quick testing of a single-case (eg. test = "test_scrobble")
|
||||
test = ""
|
||||
|
||||
if test is not None and len(test):
|
||||
|
|
Loading…
Reference in a new issue