Exemplo n.º 1
0
def test_toItem():
    visit = Visit(visitor_id, visit_date, user_number, page_title, page_slug,
                  session_start, scroll_events)
    assert visit.toItem() == {
        'PK': {
            'S': f'VISITOR#{ visitor_id }'
        },
        'SK': {
            'S': f'VISIT#{ visit_date }#{ page_slug }'
        },
        'GSI1PK': {
            'S': f'PAGE#{ page_slug }'
        },
        'GSI1SK': {
            'S': f'VISIT#{ visit_date }'
        },
        'GSI2PK': {
            'S': f'SESSION#{ visitor_id }#{ session_start }'
        },
        'GSI2SK': {
            'S': f'VISIT#{ visit_date }'
        },
        'Type': {
            'S': 'visit'
        },
        'User': {
            'N': '0'
        },
        'ScrollEvents': objectToItemAtr(scroll_events),
        'Title': {
            'S': page_title
        },
        'Slug': {
            'S': page_slug
        },
        'PreviousTitle': {
            'NULL': True
        },
        'PreviousSlug': {
            'NULL': True
        },
        'NextTitle': {
            'NULL': True
        },
        'NextSlug': {
            'NULL': True
        },
        'TimeOnPage': {
            'NULL': True
        }
    }
Exemplo n.º 2
0
def test_toItem():
    visit = Visit('2020-12-23T20:32:26.000Z', '0.0.0.0', '0', 'Tyler Norlund',
                  '/', '2020-12-23T20:32:26.000Z')
    assert visit.toItem() == {
        'PK': {
            'S': 'VISITOR#0.0.0.0'
        },
        'SK': {
            'S': 'VISIT#2020-12-23T20:32:26.000Z#/'
        },
        'GSI1PK': {
            'S': 'PAGE#/'
        },
        'GSI1SK': {
            'S': 'VISIT#2020-12-23T20:32:26.000Z'
        },
        'GSI2PK': {
            'S': 'SESSION#0.0.0.0#2020-12-23T20:32:26.000Z'
        },
        'GSI2SK': {
            'S': 'VISIT#2020-12-23T20:32:26.000Z'
        },
        'Type': {
            'S': 'visit'
        },
        'User': {
            'N': '0'
        },
        'Title': {
            'S': 'Tyler Norlund'
        },
        'Slug': {
            'S': '/'
        },
        'PreviousTitle': {
            'NULL': True
        },
        'PreviousSlug': {
            'NULL': True
        },
        'NextTitle': {
            'NULL': True
        },
        'NextSlug': {
            'NULL': True
        },
        'TimeOnPage': {
            'NULL': True
        }
    }
Exemplo n.º 3
0
def test_itemToVisit():
    visit = Visit(visitor_id, visit_date, user_number, page_title, page_slug,
                  session_start, scroll_events)
    item = visit.toItem()
    newVisit = itemToVisit(item)
    assert newVisit.id == visit.id
    assert newVisit.date == visit.date
    assert newVisit.user == visit.user
    assert newVisit.title == visit.title
    assert newVisit.slug == visit.slug
    assert newVisit.sessionStart == visit.sessionStart
    assert newVisit.prevTitle == visit.prevTitle
    assert newVisit.prevSlug == visit.prevTitle
    assert newVisit.nextTitle == visit.nextTitle
    assert newVisit.nextSlug == visit.nextSlug
    assert newVisit.timeOnPage == visit.timeOnPage
Exemplo n.º 4
0
def test_itemToVisit():
    visit = Visit('2020-12-23T20:32:26.000Z', '0.0.0.0', '0', 'Tyler Norlund',
                  '/', '2020-12-23T20:32:26.000Z')
    item = visit.toItem()
    newVisit = itemToVisit(item)
    assert newVisit.date == visit.date
    assert newVisit.ip == visit.ip
    assert newVisit.user == visit.user
    assert newVisit.title == visit.title
    assert newVisit.slug == visit.slug
    assert newVisit.sessionStart == visit.sessionStart
    assert newVisit.prevTitle == visit.prevTitle
    assert newVisit.prevSlug == visit.prevTitle
    assert newVisit.nextTitle == visit.nextTitle
    assert newVisit.nextSlug == visit.nextSlug
    assert newVisit.timeOnPage == visit.timeOnPage