1
0
mirror of https://github.com/balkian/bitter.git synced 2025-08-30 07:12:20 +00:00

Drone tests, fixed get_credentials

This commit is contained in:
J. Fernando Sánchez
2016-09-15 13:56:17 +02:00
parent 17f589c710
commit 6ebb82ba54
12 changed files with 93 additions and 21 deletions

View File

@@ -1,9 +0,0 @@
from unittest import TestCase
from bitter.crawlers import TwitterWorker, TwitterQueue
class TestWorker(TestCase):
def test_worker(self):
w = TwitterWorker()

View File

@@ -1,6 +0,0 @@
from unittest import TestCase
class TestModels(TestCase):
def test_worker(self):
assert True

View File

@@ -1,7 +1,50 @@
from unittest import TestCase
import os
from bitter import utils
from bitter import config as c
class TestUtils(TestCase):
def test_get_user(self):
assert True
def setUp(self):
self.credfile = '/tmp/credentials.txt'
c.CREDENTIALS = self.credfile
if os.path.exists(self.credfile):
os.remove(self.credfile)
utils.create_credentials(self.credfile)
def test_create_credentials(self):
assert os.path.exists(self.credfile)
os.remove(self.credfile)
utils.create_credentials() # From config
assert os.path.exists(self.credfile)
def test_add_credentials(self):
utils.add_credentials(self.credfile, user="test")
assert utils.get_credentials(self.credfile)
assert utils.get_credentials(user="test")
assert list(utils.get_credentials(user="test"))[0]["user"] == "test"
def test_get_credentials(self):
utils.add_credentials(self.credfile, user="test")
assert utils.get_credentials(user="test")
assert not utils.get_credentials(user="test", inverse=True)
def test_add_two_credentials(self):
utils.add_credentials(self.credfile, user="test")
utils.add_credentials(self.credfile, user="test2")
assert utils.get_credentials(user="test")
assert utils.get_credentials(user="test2")
def test_delete_credentials(self):
utils.add_credentials(self.credfile, user="test")
assert utils.get_credentials(user="test")
utils.delete_credentials(user="test")
print(utils.get_credentials())
assert not utils.get_credentials(user="test")