Beispiel #1
0
def test():
    conf = dbConfig.dbConfig()
    host = conf.Obj['host']
    port = conf.Obj['port']
    testDB = dbConfig.test
    print 'Host: ' + host
    print 'Port: ' + str(port)

    test = frame.frame(host,port,testDB)

    
    key1 = 'key1'
    key2 = 'key2'
    value1 = 'value1'
    value2 = 'value2'

    print 'Append to NonExistent Key (F): ' + str(test.append(key1,value1))
    print 'Create New Key (T): ' + str(test.store(key1,value1))
    print 'Append to Existent Key (T): ' + str(test.append(key1,value2, ','))
    print 'Print Appended Key value ("value1,value2"): ' + str(test.check(key1))
    print 'Check Key exists (T): ' + str(test.exists(key1))
    print 'Delete Key (T): ' + str(test.delete(key1))
    print 'Check NonExistent Key (F): ' + str(test.exists(key1))
              created_date=datetime.date(2018, 2, 1),
              updated_date=datetime.date(2018, 2, 1)),
     Customer(name='TestCustomer 3',
              created_date=datetime.date(2018, 3, 1),
              updated_date=datetime.date(2018, 3, 1)),
     Customer(name='TestCustomer 4',
              created_date=datetime.date(2018, 4, 1),
              updated_date=datetime.date(2018, 4, 1)),
     Customer(name='TestCustomer 5',
              created_date=datetime.date(2018, 4, 1),
              updated_date=datetime.date(2018, 4, 1)),
     Customer(name='TestCustomer 6',
              created_date=datetime.date(2018, 5, 1),
              updated_date=datetime.date(2018, 5, 1))
 ]
 DBConfig = dbConfig()
 dbConnection = DBConnection(DBConfig.host, DBConfig.user,
                             DBConfig.password, DBConfig.dbName)
 dbConnection.connect()
 connection = dbConnection.get_connection()
 if connection is not None:
     print("Connected")
     dbPopulate = DBPopulate(connection)
     dbPopulate.populate_country('New Zealand')
     dbPopulate.populate_customer_type('TestCustomer')
     dbPopulate.populate_sales_channel(0x0, "sales channel 1")
     dbPopulate.populate_product_category("Description of product category",
                                          "product_category 1")
     dbPopulate.populate_region('New Zealand', 'Manawatu')
     dbPopulate.populate_kiosk('Manawatu', "UnitTest", "my_api_key")
     for customer in customers:
Beispiel #3
0
 def __init__(self):
     self.attended = False
     self.average = 0
     self.db = dbConfig()
     self.studentTable = self.db.table
Beispiel #4
0
#!/bin/env python
#User class for an object to maintain user state
import frame
import hashlib
import random
import dbConfig
import login

conf = dbConfig.dbConfig()
auth = frame.frame(conf.Obj['host'], conf.Obj['port'], dbConfig.user)
session = frame.frame(conf.Obj['host'], conf.Obj['port'], dbConfig.session)
TTL = 300

class User:
    def __init__(self, username=None,userID=None):
        self.username = username
        self.userID = userID
        if self.userID == None:
            self.userID = login.getuserID(username)
        else:
            self.userID = userID

        self.sessionID = 0
        self.items = {}#itemID:item_name
        #self.wallet = {} #dictionary of BTC wallet <nickname>:<addr>
    def populate(self):
        
        self.userID = login.getuserID(self.username)
        #Cast to string to get first digits, cast to int for use as sessionID
        self.sessionID = int(str(random.getrandbits(128))[:17])
        session_key = str(self.sessionID)