Exemple #1
0
def test_full_put_news(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.put_news(
        id=1,
        title="Test Title",
        content="Test Content",
        start="2019-06-01T12:00:00",
        end="2019-06-01T18:00:00",
        groups=["Kommandanten","Ausbilder"],
        mailinglists=["Kommando-ML","Ausbilder-ML"],
        site="Gerätehaus")
    mock_requests.put.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news/1",
        data='{'
             '"title": "Test Title", '
             '"content": "Test Content", '
             '"start": "2019-06-01T12:00:00", '
             '"end": "2019-06-01T18:00:00", '
             '"groups": ["Kommandanten", "Ausbilder"], '
             '"mailinglists": ["Kommando-ML", "Ausbilder-ML"], '
             '"site": "Ger\\u00e4tehaus"'
             '}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'put news' complete")
Exemple #2
0
def test_full_put_news(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.put_news(id=1,
                 title="Test Title",
                 content="Test Content",
                 start="2019-06-01T12:00:00",
                 end="2019-06-01T18:00:00",
                 groups=["Kommandanten", "Ausbilder"],
                 mailinglists=["Kommando-ML", "Ausbilder-ML"],
                 site="Gerätehaus")
    mock_requests.put.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news/1",
        data='{'
        '"title": "Test Title", '
        '"content": "Test Content", '
        '"start": "2019-06-01T12:00:00", '
        '"end": "2019-06-01T18:00:00", '
        '"groups": ["Kommandanten", "Ausbilder"], '
        '"mailinglists": ["Kommando-ML", "Ausbilder-ML"], '
        '"site": "Ger\\u00e4tehaus"'
        '}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'put news' complete")
Exemple #3
0
def test_error_put_news(mock_requests, mock_error):
    mock_requests.put.return_value.status_code = 401
    mock_requests.put.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.put_news(
        id=1,
        title="Test Title",
        content="Test Content",
        start="2019-06-01T12:00:00",
        end="2019-06-01T18:00:00")
    mock_error.assert_called_with("Error while sending API call 'put news': 401 unauthorized")
Exemple #4
0
def test_error_put_news(mock_requests, mock_error):
    mock_requests.put.return_value.status_code = 401
    mock_requests.put.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.put_news(id=1,
                 title="Test Title",
                 content="Test Content",
                 start="2019-06-01T12:00:00",
                 end="2019-06-01T18:00:00")
    mock_error.assert_called_with(
        "Error while sending API call 'put news': 401 unauthorized")
Exemple #5
0
def test_minimal_put_news(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.put_news(
        id=1,
        title="Test Title",
        content="Test Content",
        start="2019-06-01T12:00:00",
        end="2019-06-01T18:00:00")
    mock_requests.put.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news/1",
        data='{"title": "Test Title", "content": "Test Content", "start": "2019-06-01T12:00:00", "end": "2019-06-01T18:00:00"}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'put news' complete")
Exemple #6
0
def test_minimal_put_news(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.put_news(id=1,
                 title="Test Title",
                 content="Test Content",
                 start="2019-06-01T12:00:00",
                 end="2019-06-01T18:00:00")
    mock_requests.put.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news/1",
        data=
        '{"title": "Test Title", "content": "Test Content", "start": "2019-06-01T12:00:00", "end": "2019-06-01T18:00:00"}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'put news' complete")