示例#1
0
def test_writeContactHistory_currentFieldInc():
    # Drop contactHistory before new UT
    db.contactHistory.drop()
    # Create ContactHistory with _currentField
    dataOutOldRec = dwmAll(data=test_records.record_writeContactHistory_historyCurrent1, db=db, configName='test_writeContactHistory_writeConfig')

    # Create new ContactHistory with _currentField and increment old record.
    dataOutNextRec = dwmAll(data=test_records.record_writeContactHistory_historyCurrent2, db=db, configName='test_writeContactHistory_writeConfig')

    # Get old rec with incremented _current
    hist = db.contactHistory.find_one({"_id": dataOutOldRec[0]['historyId']})
    assert hist['_current'] == 1
示例#2
0
def test_writeContactHistory_writeConfig():

    dataOut = dwmAll(data = test_records.record_writeContactHistory_writeConfig, db = db, configName='test_writeContactHistory_writeConfig')

    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})

    assert hist['configName'] == 'test_writeContactHistory_writeConfig'
示例#3
0
def test_udf_beforeGenericValidation():

    dataOut = dwmAll(data = test_records.record_udf_beforeGenericValidation, db = db, configName='test_udf_beforeGenericValidation', udfNamespace=__name__)
    assert dataOut[0]['field1'] == 'goodvalue'
示例#4
0
def test_lookupAll_genericLookup_notChecked():

    dataOut = dwmAll(data = test_records.record_lookupAll_genericLookup_notChecked, db = db, configName='test_lookupAll_genericLookup')
    assert dataOut[0]['field2'] != ''
示例#5
0
def test_history_normRegex_caught():

    dataOut = dwmAll(data = test_records.history_normRegex_caught, db = db, configName='test_regexAll_normRegex')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert hist['field1']['normRegex']['from'] == 'badvalue'
示例#6
0
def test_verbose():

    dataOut = dwmAll(data = test_records.record_lookupAll_genericLookup_caught, db = db, configName='test_lookupAll_genericLookup', verbose=True)
    assert dataOut[0]['field1'] == ''
示例#7
0
def test_dwmAll_requiresOneConfig():

    dataOut = dwmAll(data = test_records.record_dwmAll_noConfig, db = db, config={"configName": "testConfig"}, configName="testConfig", udfNamespace=__name__)
示例#8
0
def test_udf_beforeDeriveData():

    dataOut = dwmAll(data = test_records.record_udf_beforeDeriveData, db = db, configName='test_udf_beforeDeriveData', udfNamespace=__name__)
    assert dataOut[0]['field1'] == 'goodvalue'
示例#9
0
def test_udf_sort():

    dataOut = dwmAll(data = test_records.record_udf_sort, db = db, configName='test_udf_sort', udfNamespace=__name__)
    assert dataOut[0]['field1'] == 'goodvalue'
示例#10
0
def test_history_deriveIncludes_ends_caught():

    dataOut = dwmAll(data = test_records.history_deriveIncludes_ends_caught, db = db, configName='test_deriveAll_deriveIncludes')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert hist['field1']['deriveIncludes']['from'] == ''
示例#11
0
def test_history_deriveIncludes_notChecked():

    dataOut = dwmAll(data = test_records.history_deriveIncludes_notChecked, db = db, configName='test_deriveAll_deriveIncludes')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert 'field3' not in hist.keys()
示例#12
0
def test_history_deriveRegex_uncaught():

    dataOut = dwmAll(data = test_records.history_deriveRegex_uncaught, db = db, configName='test_deriveAll_deriveRegex')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert 'field1' not in hist.keys()
示例#13
0
def test_history_deriveRegex_blankIfNoMatch():

    dataOut = dwmAll(data = test_records.history_deriveRegex_blankIfNoMatch, db = db, configName='test_deriveAll_deriveRegex_blankIfNoMatch')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert hist['field1']['deriveRegex']['pattern'] == 'no matching pattern'
示例#14
0
def test_history_copyValue():

    dataOut = dwmAll(data = test_records.history_copyValue, db = db, configName='test_deriveAll_copyValue')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert hist['field1']['copyValue']['from'] == ''
示例#15
0
def test_history_normRegex_notChecked():

    dataOut = dwmAll(data = test_records.history_normRegex_notChecked, db = db, configName='test_regexAll_normRegex')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert 'field2' not in hist.keys()
示例#16
0
def test_history_normRegex_uncaught():

    # do stuff for testing
    dataOut = dwmAll(data = test_records.history_normRegex_uncaught, db = db, configName='test_regexAll_normRegex')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert 'field1' not in hist.keys()
示例#17
0
def test_udf_beforeFieldSpecificRegex():

    dataOut = dwmAll(data = test_records.record_udf_beforeFieldSpecificRegex, db = db, configName='test_udf_beforeFieldSpecificRegex', udfNamespace=__name__)
    assert dataOut[0]['field1'] == 'goodvalue'
示例#18
0
def test_history_deriveIncludes_overwriteFalse():

    dataOut = dwmAll(data = test_records.history_deriveIncludes_overwriteFalse, db = db, configName='test_deriveAll_deriveIncludes_overwriteFalse')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert 'field1' not in hist.keys()
示例#19
0
def test_udf_beforeNormalizationIncludes():

    dataOut = dwmAll(data = test_records.record_udf_beforeNormalizationIncludes, db = db, configName='test_udf_beforeNormalizationIncludes', udfNamespace=__name__)
    assert dataOut[0]['field1'] == 'goodvalue'
示例#20
0
def test_history_deriveIncludes_blankIfNoMatch():

    dataOut = dwmAll(data = test_records.history_deriveIncludes_blankIfNoMatch, db = db, configName='test_deriveAll_deriveIncludes_blankIfNoMatch')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert hist['field1']['deriveIncludes']['using']['blankIfNoMatch'] == 'no match found'
示例#21
0
def test_udf_afterProcessing():

    dataOut = dwmAll(data = test_records.record_udf_afterProcessing, db = db, configName='test_udf_afterProcessing', udfNamespace=__name__)
    assert dataOut[0]['field1'] == 'goodvalue'
示例#22
0
def test_returnHistoryId_False():

    dataOut = dwmAll(data = test_records.record_returnHistoryId_False, db = db, configName='test_returnHistoryId_False')
    assert 'historyId' not in dataOut[0].keys()
示例#23
0
def test_udf_afterProcessing_invalidFcn():

    dataOut = dwmAll(data = test_records.record_udf_afterProcessing_invalidFcn, db = db, configName='test_udf_afterProcessing_invalidFcn', udfNamespace=__name__)
示例#24
0
def test_writeContactHistory_False():

    dataOut = dwmAll(data = test_records.record_writeContactHistory_False, db = db, configName='test_writeContactHistory_False')
    assert 'historyId' not in dataOut[0].keys()
示例#25
0
def test_dwmAll_requiresConfigInput():

    dataOut = dwmAll(data = test_records.record_dwmAll_noConfig, db = db, udfNamespace=__name__)
示例#26
0
def test_history_normIncludes_caught():

    # do stuff for testing
    dataOut = dwmAll(data = test_records.history_normIncludes_included_caught, db = db, configName='test_normIncludes')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert hist['field1']['normIncludes']['from'] == 'findgoodinvaluejunk'
示例#27
0
def test_lookupAll_genericLookup_uncaught():

    dataOut = dwmAll(data = test_records.record_lookupAll_genericLookup_uncaught, db = db, configName='test_lookupAll_genericLookup')
    assert dataOut[0]['field1'] != ''
示例#28
0
def test_configDoesNotExist():

    dataOut = dwmAll(data = test_records.record_configDoesNotExist, db = db, configName='test_configDoesNotExist')
示例#29
0
    clientConfig.close()

    ###############################################################################
    ## Run the DWM
    ###############################################################################

    ## connect to mongo
    client = MongoClient(os.environ['MONGODB_URL'])
    db = client['dwmdev']
    logging.info("Connected to mongo")

    ## Run DWM
    dwmStart = datetime.now()
    dataOut = dwm.dwmAll(data=job,
                         db=db,
                         config=config,
                         udfNamespace=__name__,
                         verbose=True)
    dwmEnd = datetime.now()

    client.close()

    ###############################################################################
    ## Put them into the processedQueue; remove from exportQueue
    ###############################################################################

    indicatorQueue.add(dataOut, transfer=True)

    exportQueue.complete(job)

else:
示例#30
0
def test_history_normIncludes_uncaught():

    dataOut = dwmAll(data = test_records.history_normIncludes_included_uncaught, db = db, configName='test_normIncludes')
    hist = db.contactHistory.find_one({"_id": dataOut[0]['historyId']})
    assert 'field1' not in hist.keys()