Created
September 16, 2013 16:52
-
-
Save garethr/6583309 to your computer and use it in GitHub Desktop.
Example nose based unit test against librato metrics API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> nosetests -v rkhunter-librato-test.py | |
rkhunter-libratoo-test.test_beastkit_not_installed ... ok | |
---------------------------------------------------------------------- | |
Ran 1 test in 1.585s | |
OK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import librato | |
USER = os.environ['LIBRATO_USER'] | |
PASSWORD = os.environ['LIBRATO_PASSWORD'] | |
API = librato.connect(USER, PASSWORD) | |
def value_of_metric(metric_name): | |
return API.get(metric_name, count=1, resolution=1).measurements['unassigned'][0]['value'] | |
def test_beastkit_not_installed(): | |
assert (value_of_metric("beastkit_rootkit") == 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment