Пример #1
0
def test_deduplicate_is_duplicate_no_investigation_id():
    #  Setup dedup_hash for this event (without investigation id)
    client = boto3.client('dynamodb')
    client.put_item(TableName=os.environ['SOCLESS_DEDUP_TABLE'],
                    Item=dict_to_item(
                        {"dedup_hash": DEDUP_HASH_FOR_MOCK_EVENT},
                        convert_root=False))

    # investigation_id NOT saved in dedup table, not duplicate
    event = EventCreator(MOCK_EVENT)
    event.deduplicate()
    assert event.status_ == 'open'
    assert event.is_duplicate == False
Пример #2
0
def test_deduplicate_is_duplicate_status_closed():
    #  Setup tables for this event
    client = boto3.client('dynamodb')
    client.put_item(TableName=os.environ['SOCLESS_DEDUP_TABLE'],
                    Item=dict_to_item(
                        {
                            "dedup_hash": DEDUP_HASH_FOR_MOCK_EVENT,
                            "current_investigation_id": MOCK_INVESTIGATION_ID
                        },
                        convert_root=False))
    client.put_item(TableName=os.environ['SOCLESS_EVENTS_TABLE'],
                    Item=dict_to_item(
                        {
                            "id": MOCK_INVESTIGATION_ID,
                            'investigation_id': "already_running_id",
                            'status_': 'closed'
                        },
                        convert_root=False))

    event = EventCreator(MOCK_EVENT)
    event.deduplicate()
    assert event.is_duplicate == False
    assert event.status_ == 'open'
Пример #3
0
def test_deduplicate_is_unique():
    event = EventCreator(MOCK_EVENT)
    event.deduplicate()
    assert event.status_ == 'open'
    assert event.is_duplicate == False
Пример #4
0
def test_deduplicate_unique():
    event = EventCreator(MOCK_EVENT)
    event.deduplicate()
    pass