コード例 #1
0
    def __init__(self):
        self.srcCKANWrapper = CKAN.CKANWrapper(
            os.environ[constants.CKAN_URL_SRC],
            os.environ[constants.CKAN_APIKEY_SRC])

        self.destCKANWrapper = CKAN.CKANWrapper(
            os.environ[constants.CKAN_URL_DEST],
            os.environ[constants.CKAN_APIKEY_DEST])
コード例 #2
0
ファイル: CKAN_fixtures.py プロジェクト: bdolor/bcdc2bcdc
def CKANAddTestUser(CKANParamsTest):
    """Some methods need the demo user to exist.  This fixture makes sure the 
    demo user exists, and that its state is set to 'active'

                "state": "active"

    After yield will revert the state to "deleted"
    """
    ckan = CKAN.CKANWrapper(CKANParamsTest['ckanUrl'],
                            CKANParamsTest['ckanAPIKey'])

    dataHelper = CKANDataHelpers.CKAN_Test_Data()
    dummyUserData = dataHelper.getTestUserData()

    dummyUser = dummyUserData[constants.TEST_USER_DATA_POSITION]
    LOGGER.debug("dummyUSer: %s", dummyUser)
    # make sure the user exists
    if not ckan.userExists(dummyUser['name']):
        retVal = ckan.addUser(dummyUserData)

    # make sure the state is active
    user = ckan.getUser(dummyUser['name'])
    LOGGER.debug("user: %s", user)
    if dummyUser['state'] != 'active':
        dummyUser['state'] = 'active'
        ckan.updateUser(dummyUser)
    yield

    # now delete the user.
    ckan.deleteUser(dummyUser['name'])
    return
コード例 #3
0
ファイル: CKAN_fixtures.py プロジェクト: bdolor/bcdc2bcdc
def CKANDeleteTestUser(CKANParamsTest):
    """makes sure at  the start of every test that uses this fixture the test
    user state is set to 'deleted'.  

    Method will ensure the state is 'deleted' before and after yield statement.
    """
    ckan = CKAN.CKANWrapper(CKANParamsTest['ckanUrl'],
                            CKANParamsTest['ckanAPIKey'])

    dataHelper = CKANDataHelpers.CKAN_Test_Data()
    dummyUserData = dataHelper.getTestUserData()

    dummyUser = dummyUserData[constants.TEST_USER_DATA_POSITION]
    if ckan.userExists(
            dummyUser['name']) and not ckan.userIsDeleted(dummyUser['name']):
        ckan.deleteUser(dummyUser['name'])
        LOGGER.info("deleted the user: %s", dummyUser)
    yield
    if ckan.userExists(
            dummyUser['name']) and not ckan.userIsDeleted(dummyUser['name']):
        time.sleep(4)
        ckan.deleteUser(dummyUser['name'])
        LOGGER.info("deleted the user: %s", dummyUser)
    return
コード例 #4
0
def CKANWrapperProd(CKANParamsProd):
    yield CKAN.CKANWrapper(url=CKANParamsProd["ckanUrl"],
                           apiKey=CKANParamsProd["ckanAPIKey"])
コード例 #5
0
def CKANWrapperTest(CKANParamsTest):
    yield CKAN.CKANWrapper(url=CKANParamsTest["ckanUrl"],
                           apiKey=CKANParamsTest["ckanAPIKey"])
コード例 #6
0
 def __init__(self, ckanWrapper=None):
     self.CKANWrap = ckanWrapper
     if ckanWrapper is None:
         self.CKANWrap = CKAN.CKANWrapper()
コード例 #7
0
ファイル: CKAN_fixtures.py プロジェクト: bdolor/bcdc2bcdc
def CKAN_Src_fixture(CKANParamsProd):
    return CKAN.CKANWrapper(CKANParamsProd['ckanUrl'],
                            CKANParamsProd['ckanAPIKey'])
コード例 #8
0
ファイル: CKAN_fixtures.py プロジェクト: bdolor/bcdc2bcdc
def CKAN_Dest_fixture(CKANParamsTest):
    return CKAN.CKANWrapper(CKANParamsTest['ckanUrl'],
                            CKANParamsTest['ckanAPIKey'])