Ejemplo n.º 1
0
 def setUpClass(cls):
     curr_dir = os.path.dirname(__file__)
     path = get_abs_path(os.path.join(curr_dir, '../fixtures/'))
     full_path = os.path.join(path, DB_FILE_NAME)
     with open(full_path, 'r') as fp:
         cls.smmdb_base = json.load(fp)
     print full_path, path
     cls._inst = SMMemory(path)
Ejemplo n.º 2
0
 def setUpClass(cls):
     curr_dir = os.path.dirname(__file__)
     path = get_abs_path(os.path.join(curr_dir, "../fixtures/"))
     full_path = os.path.join(path, DB_FILE_NAME)
     with open(full_path, "r") as fp:
         cls.smmdb_base = json.load(fp)
     print full_path, path
     cls._inst = SMMemory(path)
Ejemplo n.º 3
0
 def test_get_abs_path(self):
     """Get Linux absolute path"""
     test_cases = {
         "~": self._home,
         "tmp/dir/my_dir": os.path.join(self._cwd, "tmp/dir/my_dir"),
         "/tmp/test": "/tmp/test",
         "~/.mydir": os.path.join(self._home, ".mydir"),
     }
     for key, value in test_cases.iteritems():
         self.assertEqual(os.path.normpath(get_abs_path(key)), os.path.normpath(value))
Ejemplo n.º 4
0
 def test_get_abs_path(self):
     """Get Linux absolute path"""
     test_cases = {
         "~": self._home,
         "tmp/dir/my_dir": os.path.join(self._cwd, "tmp/dir/my_dir"),
         "/tmp/test": "/tmp/test",
         "~/.mydir": os.path.join(self._home, ".mydir")
     }
     for key, value in test_cases.iteritems():
         self.assertEqual(os.path.normpath(get_abs_path(key)),
                          os.path.normpath(value)
                          )
Ejemplo n.º 5
0
from smm.utils import get_env, get_abs_path

# Templates
tmpl_missing_key = string.Template('Missing key [$key].')

DB_FILE_NAME = 'smmdbstore.json'
DB_DEF_PATH = '~/.smmdbstore/'
DB_FILE_NAME_BKP = '.' + DB_FILE_NAME + '.backup'
GROUP_ID = '__groups__'
DATA_ID = '__data__'
COUNT_ID = '__count__'
OWNER_ID = '__owner__'
COMM_TEXT = 'text'
COMM_GROUP = 'group'
COMM_DESC = 'description'
DB_PATH = get_env('SMMENVDBPATH', def_value=get_abs_path('~/.smmdbstore'))

INIT_STATE = {
    DATA_ID: {},
    GROUP_ID: [],
    COUNT_ID: 0,
    OWNER_ID: "anonymous"
}


class SmmDBCorrupted(Exception):
    pass


class SmmDBKeyError(Exception):
    pass
Ejemplo n.º 6
0
from smm.utils import get_env, get_abs_path

# Templates
tmpl_missing_key = string.Template('Missing key [$key].')

DB_FILE_NAME = 'smmdbstore.json'
DB_DEF_PATH = '~/.smmdbstore/'
DB_FILE_NAME_BKP = '.' + DB_FILE_NAME + '.backup'
GROUP_ID = '__groups__'
DATA_ID = '__data__'
COUNT_ID = '__count__'
OWNER_ID = '__owner__'
COMM_TEXT = 'text'
COMM_GROUP = 'group'
COMM_DESC = 'description'
DB_PATH = get_env('SMMENVDBPATH', def_value=get_abs_path('~/.smmdbstore'))

INIT_STATE = {DATA_ID: {}, GROUP_ID: [], COUNT_ID: 0, OWNER_ID: "anonymous"}


class SmmDBCorrupted(Exception):
    pass


class SmmDBKeyError(Exception):
    pass


class SmmDBKeyDuplicate(Exception):
    pass