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])
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
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
def CKANWrapperProd(CKANParamsProd): yield CKAN.CKANWrapper(url=CKANParamsProd["ckanUrl"], apiKey=CKANParamsProd["ckanAPIKey"])
def CKANWrapperTest(CKANParamsTest): yield CKAN.CKANWrapper(url=CKANParamsTest["ckanUrl"], apiKey=CKANParamsTest["ckanAPIKey"])
def __init__(self, ckanWrapper=None): self.CKANWrap = ckanWrapper if ckanWrapper is None: self.CKANWrap = CKAN.CKANWrapper()
def CKAN_Src_fixture(CKANParamsProd): return CKAN.CKANWrapper(CKANParamsProd['ckanUrl'], CKANParamsProd['ckanAPIKey'])
def CKAN_Dest_fixture(CKANParamsTest): return CKAN.CKANWrapper(CKANParamsTest['ckanUrl'], CKANParamsTest['ckanAPIKey'])