def setUp(self):

        from tests import helpers
        self.helper = reload(helpers)

        self.dbname = 'tmpDB'
        self.myreg = reg.Reg(self.dbname)
Exemple #2
0
 def setUp(self):
     self.myreg = reg.Reg(db_name)
     self.mock_objs = {}
     for role in [
             ce.Freelance, ce.TaxPayer, ce.TaxEmployee, ce.Developer,
             ce.Accountant
     ]:
         self.myreg.add_role(role)
Exemple #3
0
    def setUp(self):
        self.myreg = reg.Reg(db_name)

        rows = [('company', 'a', 'a', 'b', 'PPR', 1, 1),
                ('company', 'a', 'a', 'c', 'PPR', 1, 2),
                ('company', 'a', 'c', 'd', 'RPR', 2, 1),
                ('company', 'a', 'c', 'e', 'RPR', 2, 2),
                ('company', 'a', 'c', 'f', 'RPR', 2, 3),
                ('company', 'a', 'e', 'g', 'RPR', 3, 1),
                ('company', 'a', 'g', 'h', 'RPR', 4, 1),
                ('company', 'a', 'g', 'i', 'RPR', 4, 2),
                ('company', 'a', 'f', 'j', 'RPR', 3, 2)]
        self.myreg.conn.executemany(
            'INSERT INTO {} VALUES(?, ?, ?, ?, ?, ?, ?)'.format(db_name), rows)
Exemple #4
0
    def setUp(self):
        self.myreg = reg.Reg(db_name)
        ca = self.C_A()
        pa = self.P_A()
        rb = self.R_B()
        rc = self.R_C()
        rd = self.R_D()
        re = self.R_E()
        rf = self.R_F()
        rg = self.R_G()
        rh = self.R_H()
        ri = self.R_I()
        rj = self.R_J()
        self.myreg.bind(ca, pa, pa, rb, 'PPR')
        self.myreg.bind(ca, pa, pa, rc, 'PPR')
        self.myreg.bind(ca, pa, rc, rd, 'RPR')
        self.myreg.bind(ca, pa, rc, re, 'RPR')
        self.myreg.bind(ca, pa, rc, rf, 'RPR')
        self.myreg.bind(ca, pa, re, rg, 'RPR')
        self.myreg.bind(ca, pa, re, rj, 'RPR')
        self.myreg.bind(ca, pa, rg, rh, 'RPR')
        self.myreg.bind(ca, pa, rg, ri, 'RPR')

        ## basically load the classes to g
        #for player in [pa]:
        #    g.players[player.uuid] = player

        #for compartment in [ca]:
        #    g.compartments[compartment.classtype] = compartment

        #for role in [rb, rc, rd, re, rf, rg, rh, ri, rj]:
        #    g.roles[role.classtype] = role

        self.wholeTable = [
            ('compartmentA', 'coreA', 'coreA', 'b', 'PPR', 1, 1),
            ('compartmentA', 'coreA', 'coreA', 'c', 'PPR', 1, 2),
            ('compartmentA', 'coreA', 'c', 'd', 'RPR', 2, 1),
            ('compartmentA', 'coreA', 'c', 'e', 'RPR', 2, 2),
            ('compartmentA', 'coreA', 'c', 'f', 'RPR', 2, 3),
            ('compartmentA', 'coreA', 'e', 'g', 'RPR', 3, 1),
            ('compartmentA', 'coreA', 'e', 'j', 'RPR', 3, 2),
            ('compartmentA', 'coreA', 'g', 'h', 'RPR', 4, 1),
            ('compartmentA', 'coreA', 'g', 'i', 'RPR', 4, 2)
        ]

        resultFetched = self.myreg.conn.execute("SELECT * FROM {} ".format(
            self.myreg.name)).fetchall()
        # assure the table is right. If something change the test should fail
        self.assertEquals(self.wholeTable, resultFetched)
 def setUp(self):
     self.dbname = 'tmpDB'
     self.myreg = reg.Reg(self.dbname)
Exemple #6
0
#!/usr/bin/python3

from libs import reg, g
from libs.monitor import start_monitor_thread
import app.company_example as ce
import time

myreg = reg.Reg('roles_db')
monitor = start_monitor_thread('runtime_lib', myreg)

company = ce.Company(100000, id='company')
bob = ce.Person('bob', 10000, id='bob')
for role in [ce.Developer, ce.TaxPayer]:
    myreg.add_role(role)

developer = g.nspace['developer'](100, id='developer')
taxpayer = g.nspace['taxpayer'](id='taxpayer')

myreg.bind(company, bob, bob, developer, 'PPR')
myreg.invokeRole(company, bob, 'pay')
myreg.bind(company, bob, developer, taxpayer, 'RPR')
myreg.invokeRole(company, bob, 'pay')
myreg.unbind('bob', 'taxpayer')
myreg.invokeRole(company, bob, 'pay')


while True:
    time.sleep(1)
    myreg.invokeRole(company, bob, 'work')
    myreg.invokeRole(company, bob, 'getPaid')
    print('Hi, I am {}. {}'.format(bob.name, myreg.invokeRole(company, bob, 'show_savings')))
Exemple #7
0
 def test_db_creation(self):
     args = "CompartmentId text, CorePlayerId text, PlayerId text, RoleId text, RelationType text, " \
            "BindingLevel integer, BindingSequence integer"
     mydb = reg.Reg('tmp_db')
     self.assertTrue(mydb.conn is not None)
     mydb.conn.close()
Exemple #8
0
    def setUp(self):
        self.filepath = os.path.abspath('.') + '/runtime_lib/test0.py'
        helpers.remove_tmp_files()
        self.myreg = reg.Reg('dumb_db')

        self.monitor = start_monitor_thread('runtime_lib', self.myreg)