Пример #1
0
def test_create_adds_page_to_db(Language):
    """
        This should add the new page to the database session, which is added only if it does not exit in a db.
        After successfully creating a new page it should redirect.
    """
    language = mock.Mock()
    Language.return_value = language

    request = _mock_request(matchdict={'language_name': 'test', 'public_group_id': 12345,
                                       'page_url': 'http://www.annotran_testing.com'})
    result = views.add_page(request)

    request.db.add.assert_called_once()
    assert isinstance(result, httpexceptions.HTTPRedirection)
Пример #2
0
def test_create_redirects_to_page_read_page(Page, Language):
    """
        After successfully fetching mock Page and Language objects it
         should not add that page into db but it should redirect.
    """
    language = mock.Mock()
    Language.return_value = language
    page = mock.Mock(id=1)
    Page.return_value = page

    request = _mock_request(matchdict={'language_name': 'test', 'public_group_id': 12345,
                                       'page_url': 'http://www.annotran_testing.com'})
    result = views.add_page(request)
    assert not request.db.add.called
    assert isinstance(result, httpexceptions.HTTPRedirection)
Пример #3
0
def test_create_adds_page_to_db(Language):
    """
        This should add the new page to the database session, which is added only if it does not exit in a db.
        After successfully creating a new page it should redirect.
    """
    language = mock.Mock()
    Language.return_value = language

    request = _mock_request(
        matchdict={
            'language_name': 'test',
            'public_group_id': 12345,
            'page_url': 'http://www.annotran_testing.com'
        })
    result = views.add_page(request)

    request.db.add.assert_called_once()
    assert isinstance(result, httpexceptions.HTTPRedirection)
Пример #4
0
def test_create_redirects_to_page_read_page(Page, Language):
    """
        After successfully fetching mock Page and Language objects it
         should not add that page into db but it should redirect.
    """
    language = mock.Mock()
    Language.return_value = language
    page = mock.Mock(id=1)
    Page.return_value = page

    request = _mock_request(
        matchdict={
            'language_name': 'test',
            'public_group_id': 12345,
            'page_url': 'http://www.annotran_testing.com'
        })
    result = views.add_page(request)
    assert not request.db.add.called
    assert isinstance(result, httpexceptions.HTTPRedirection)