コード例 #1
0
def setup_module():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    connect()
    create_tables()
    create_default_users()
    create_root()

    grp1 = Group.create(name=GRP1_NAME)
    grp2 = Group.create(name=GRP2_NAME)
    grp3 = Group.create(name=GRP3_NAME)

    user_name = USR1_NAME
    email = uuid.uuid4().hex
    password = uuid.uuid4().hex
    administrator = True
    groups = [GRP1_NAME]
    user1 = User.create(name=user_name,
                        email=email,
                        password=password,
                        administrator=administrator,
                        groups=groups)

    user_name = USR2_NAME
    email = uuid.uuid4().hex
    password = uuid.uuid4().hex
    administrator = False
    groups = [GRP1_NAME, GRP2_NAME]
    user2 = User.create(name=user_name,
                        email=email,
                        password=password,
                        administrator=administrator,
                        groups=groups)
コード例 #2
0
def setup_module():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    connect()
    create_tables()
    create_default_users()
    create_root()
コード例 #3
0
def setup_module():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    connect()
    create_tables()
    create_root()
    Group.create(name="grp1")
コード例 #4
0
def test_destroy():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    create_keyspace_simple(TEST_KEYSPACE, 1, True)
    cluster = connection.get_cluster()
    assert TEST_KEYSPACE in cluster.metadata.keyspaces
    destroy()
    assert TEST_KEYSPACE not in cluster.metadata.keyspaces
コード例 #5
0
def test_initialise():
    cfg.dse_keyspace = TEST_KEYSPACE
    assert initialise() == True
    cluster = connection.get_cluster()
    # Check keyspace has been created
    assert cfg.dse_keyspace in cluster.metadata.keyspaces
    # Keyspace should already exist
    assert initialise() == True
    destroy()
コード例 #6
0
def test_creation():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    create_tables()
    create_default_users()
    create_root()
    # Test creation if they already exist
    create_default_users()
    destroy()
コード例 #7
0
def test_tables():
    cfg.dse_keyspace = TEST_KEYSPACE

    # list of tables that has to be created
    ls_tables = {'data_object', 'group', 'notification', 'tree_node', 'user'}
    initialise()
    create_tables()
    cluster = connection.get_cluster()
    created_tables = set(
        cluster.metadata.keyspaces[TEST_KEYSPACE].tables.keys())
    assert created_tables.difference(ls_tables) == set()
    destroy()
コード例 #8
0
def setup_module():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    connect()
    create_tables()
    create_root()
    try:
        coll = Collection.create("/", "coll1")
        ref1 = Resource.create("/", "test.url", url=TEST_URL)
        resc = Resource.create("/coll1", "test.txt")
        ref2 = Resource.create("/coll1", "test.url", url=TEST_URL)
    except:  # If collections or resources already exist
        pass
コード例 #9
0
def test_keyspace_network_topology():
    """We would need a correct setup with multiple data centers to test this
    correctly"""
    cfg.dse_keyspace = TEST_KEYSPACE
    cfg.dse_strategy = "NetworkTopologyStrategy"
    cfg.dse_dc_replication_map = {"dc1": 1}
    assert initialise() == True
    destroy()
コード例 #10
0
def test_fail_connection_setup(mocker):
    # Raise a fake exception to test all parts of the connection code
    mocker.patch('dse.cqlengine.connection.setup',
                 side_effect=dse.cluster.NoHostAvailable(
                     "My Fake Error", {"127.0.0.1": Exception()}))
    # Deactivate the sleep method to sped up tests
    mocker.patch("time.sleep", return_value=True)
    assert initialise() == False
コード例 #11
0
def test_keyspace_simple():
    cfg.dse_keyspace = TEST_KEYSPACE
    cfg.dse_strategy = "SimpleStrategy"

    assert initialise() == True
    cluster = connection.get_cluster()
    # Check keyspace has been created
    assert TEST_KEYSPACE in cluster.metadata.keyspaces
    destroy()
    # Check keyspace has been deleted
    assert TEST_KEYSPACE not in cluster.metadata.keyspaces
コード例 #12
0
def setup_module():
    cfg.dse_keyspace = TEST_KEYSPACE
    initialise()
    connect()
    create_tables()
    create_default_users()
    create_root()
    pwd = uuid.uuid4().hex
    email = uuid.uuid4().hex
    grp1 = Group.create(name="grp1")
    u1 = User.create(name="user1",
                     password=pwd,
                     email=email,
                     administrator=True)
    u2 = User.create(name="user2",
                     password=pwd,
                     email=email,
                     administrator=False)

    grp1.add_users(["user2"])

    try:
        coll = Collection.create("/", "1")
        coll = Collection.create("/1", "11")
        coll = Collection.create("/1", "12")
        coll = Collection.create("/1", "13")
        coll = Collection.create("/", "2")
        coll = Collection.create("/2", "21")
        coll = Collection.create("/2/21", "211")
        coll = Collection.create("/2/21", "212")
        r = Resource.create("/1/11", "a")
        r = Resource.create("/1/11", "b", url=TEST_URL)
        r = Resource.create("/1/12", "c")
        r = Resource.create("/1/13", "d")
        r = Resource.create("/2/21/211", "e")
        r = Resource.create("/2/21/212", "f")
        r = Resource.create("/", "g")
    except:  # If collections or resources already exist
        pass
コード例 #13
0
    def ready(self):
        initialise()

        # Try to get the root. It will be created if it doesn't exist
        coll = Collection.get_root()
コード例 #14
0
ファイル: cli.py プロジェクト: radon-provenance/radon-lib
 def __init__(self, session_path):
     self.terminal = blessings.Terminal()
     self.session_path = session_path
     initialise()
コード例 #15
0
def test_fail_initialise(mocker):
    mocker.patch('radon.database.connect', return_value=False)
    assert initialise() == False