Esempio n. 1
0
File: cli.py Progetto: nictuku/nwu
 def __init__(self, config=None, initialize=True):
     # FIXME: remove this 'initialize' check
     # it's used the tests, but I could simply override the class instead
     if initialize:
         if not config:
             config = Config()
         # FIXME: use nwu.server.app instead when it's available
         db_bind(config.get("database", "connection_string",
             "sqlite:////var/lib/nwu/nwu.db"))
Esempio n. 2
0
from nwu.server.rpc_agents import RPC
from nwu.server.db.model import metadata, db_bind 
from nwu.server.db.model import Computer, CurrentPackages
from nwu.server.cli import Commands

log = logging.getLogger()
HDLR = logging.StreamHandler()
log.addHandler(HDLR)
log.setLevel(logging.DEBUG)
CONFIG = { 'connection_string' : 'sqlite:///' }
CLI = Commands(config=CONFIG, initialize=False)
PASSWORD = '******'
UNIQ = 'dsadsad1921832918312weee'
TOKEN = hmac.new(PASSWORD, UNIQ).hexdigest()

print "Conncted to database? %s" % repr(db_bind(CONFIG['connection_string']))
create_all()
    
class TestServer:

    def test_add_computer(self):

        assert Local.check_token(UNIQ, TOKEN) == False

        # no servers in the database
        zero = Computer.query.count()
        assert zero == 0

        # server doesn't exist yet
        session = RPC.session_setup(UNIQ, TOKEN)
        assert session == False