Example #1
0
def test_error_post_user_status(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_user_status(username="******", status="coming")
    mock_error.assert_called_with(
        "Error while sending API call 'post user status': 401 unauthorized")
Example #2
0
def test_error_delete_news(mock_requests, mock_error):
    mock_requests.delete.return_value.status_code = 401
    mock_requests.delete.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.delete_news(1)
    mock_error.assert_called_with(
        "Error while sending API call 'delete news': 401 unauthorized")
def test_error_put_alarmgroup(mock_requests, mock_error):
    mock_requests.put.return_value.status_code = 401
    mock_requests.put.return_value.text = "unauthorized"
    api = PublicAPI(TOKEN)
    api.put_alarmgroup(1, "Test Gruppe", [{"id": 1}, {"id": 2}])
    mock_error.assert_called_with(
        "Error while sending API call 'put alarmgroup': 401 unauthorized")
Example #4
0
def test_full_post_news(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.post_news(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.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news?newsType=siteNews",
        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 'post news' complete")
def test_error_get_alarmgroup(mock_requests, mock_error):
    mock_requests.get.return_value.status_code = 401
    mock_requests.get.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.get_alarmgroup()
    mock_error.assert_called_with(
        "Error while sending API call 'get alarmgroup': 401 unauthorized")
def test_error_post_operation(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_operation(start="2019-06-01T12:00:00", keyword="Brand 2")
    mock_error.assert_called_with(
        "Error while sending API call 'post operation': 401 unauthorized")
def test_full_put_alarmgroup(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    users = [{
        "id": 1,
        "firstname": "Hans",
        "lastname": "Maier",
        "email": "*****@*****.**"
    }, {
        "id": 2,
        "firstname": "Bernd",
        "lastname": "Brot",
        "email": "*****@*****.**"
    }]
    api.put_alarmgroup(1, "Test Gruppe", users)
    mock_requests.put.assert_called_once_with(
        "https://connectapi.feuersoftware.com/interfaces/public/alarmgroup/1",
        data='{'
        '"id": 1, '
        '"name": "Test Gruppe", '
        '"users": ['
        '{"id": 1, "firstname": "Hans", "lastname": "Maier", "email": "*****@*****.**"}, '
        '{"id": 2, "firstname": "Bernd", "lastname": "Brot", "email": "*****@*****.**"}'
        ']}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'put alarmgroup' complete")
Example #8
0
def test_full_put_alarmgroup(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    users = [{"id":1,
              "firstname": "Hans",
              "lastname": "Maier",
              "email": "*****@*****.**"},
            {"id":2,
             "firstname": "Bernd",
             "lastname": "Brot",
             "email": "*****@*****.**"}]
    api.put_alarmgroup(1, "Test Gruppe", users)
    mock_requests.put.assert_called_once_with(
        "https://connectapi.feuersoftware.com/interfaces/public/alarmgroup/1",
        data='{'
             '"id": 1, '
             '"name": "Test Gruppe", '
             '"users": ['
             '{"id": 1, "firstname": "Hans", "lastname": "Maier", "email": "*****@*****.**"}, '
             '{"id": 2, "firstname": "Bernd", "lastname": "Brot", "email": "*****@*****.**"}'
             ']}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'put alarmgroup' complete")
Example #9
0
def test_full_post_news(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.post_news(
        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.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news",
        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 'post news' complete")
Example #10
0
def test_error_post_operation(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_operation(
        start = "2019-06-01T12:00:00",
        keyword = "Brand 2")
    mock_error.assert_called_with("Error while sending API call 'post operation': 401 unauthorized")
Example #11
0
def test_error_post_user_status(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_user_status(
        username = "******",
        status = "coming")
    mock_error.assert_called_with("Error while sending API call 'post user status': 401 unauthorized")
def test_error_post_vehicle_status(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_vehicle_status(
        radioid = 12345,
        status = "2")
    mock_error.assert_called_with("Error while sending API call 'post vehicle status': 401 unauthorized")
Example #13
0
def test_get_news(mock_requests, mock_info):
    mock_requests.get.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.get_news()
    mock_requests.get.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news",
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'get news' complete")
Example #14
0
def test_error_post_news(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_news(
        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 'post news': 401 unauthorized")
Example #15
0
def test_error_post_news(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_news(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 'post news': 401 unauthorized")
Example #16
0
def test_minimal_put_alarmgroup(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.put_alarmgroup(1, "Test Gruppe", [{"id":1},{"id":2}])
    mock_requests.put.assert_called_once_with(
        "https://connectapi.feuersoftware.com/interfaces/public/alarmgroup/1",
        data='{"id": 1, "name": "Test Gruppe", "users": [{"id": 1}, {"id": 2}]}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'put alarmgroup' complete")
Example #17
0
def test_get_geocoding(mock_requests, mock_info):
    mock_requests.get.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.get_geocoding(
        address = "Gemeindezentrum 1b, 79790 Küssaberg")
    mock_requests.get.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/geocoding',
        data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'get geocoding' complete")
Example #18
0
def test_post_passwordcheck(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.post_passwordcheck(
        password = "******")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/passwordcheck',
        data='{"password": "******"}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'post passwordcheck' complete")
Example #19
0
def test_delete_news(mock_requests, mock_info):
    mock_requests.delete.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.delete_news(1)
    mock_requests.delete.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news/1",
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'delete news' complete")
def test_get_alarmgroup(mock_requests, mock_info):
    mock_requests.get.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.get_alarmgroup()
    mock_requests.get.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/alarmgroup",
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'get alarmgroup' complete")
Example #21
0
def test_get_geocoding(mock_requests, mock_info):
    mock_requests.get.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.get_geocoding(address="Gemeindezentrum 1b, 79790 Küssaberg")
    mock_requests.get.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/geocoding',
        data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'get geocoding' complete")
def test_post_vehicle_status_minimal(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_vehicle_status(
        radioid = 12345,
        status = "2")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/vehicle/12345/status',
        data='{"status": "2"}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'post vehicle status' complete")
Example #23
0
def test_post_user_status_minimal(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_user_status(
        username = "******",
        status = "coming")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/operation/userstatus',
        data='{"username": "******", "status": "coming"}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'post user status' complete")
Example #24
0
def test_error_get_geocoding(mock_requests, mock_error):
    mock_requests.get.return_value.status_code = 401
    mock_requests.get.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.get_geocoding(
        address = "Gemeindezentrum 1b, 79790 Küssaberg")
    mock_requests.get.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/geocoding',
        data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}',
        headers={"authorization": f"bearer ABCD",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_error.assert_called_with("Error while sending API call 'get geocoding': 401 unauthorized")
Example #25
0
def test_error_get_geocoding(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_passwordcheck(
        password = "******")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/passwordcheck',
        data='{"password": "******"}',
        headers={"authorization": f"bearer ABCD",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_error.assert_called_with("Error while sending API call 'post passwordcheck': 401 unauthorized")
Example #26
0
def test_post_passwordcheck(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.post_passwordcheck(password="******")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/passwordcheck',
        data='{"password": "******"}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with(
        "Success, API call 'post passwordcheck' complete")
def test_minimal_put_alarmgroup(mock_requests, mock_info):
    mock_requests.put.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.put_alarmgroup(1, "Test Gruppe", [{"id": 1}, {"id": 2}])
    mock_requests.put.assert_called_once_with(
        "https://connectapi.feuersoftware.com/interfaces/public/alarmgroup/1",
        data=
        '{"id": 1, "name": "Test Gruppe", "users": [{"id": 1}, {"id": 2}]}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'put alarmgroup' complete")
Example #28
0
def test_post_user_status_minimal(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_user_status(username="******", status="coming")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/operation/userstatus',
        data='{"username": "******", "status": "coming"}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with(
        "Success, API call 'post user status' complete")
Example #29
0
 def alert(self, account, alarmdata):
     """Send alarm data to Feuersoftware API."""
     api = PublicAPI(account.get("connect").get("token"))
     r = api.post_operation(
         start=alarmdata.get("start"),
         keyword=alarmdata.get("keyword"),
         status="new",
         alarmenabled=True,
         address=alarmdata.get("address"),
         facts=alarmdata.get("facts"),
         number=alarmdata.get("number"),
         properties=alarmdata.get("properties"),
         ric=alarmdata.get("ric"),
     )
Example #30
0
def test_error_get_geocoding(mock_requests, mock_error):
    mock_requests.get.return_value.status_code = 401
    mock_requests.get.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.get_geocoding(address="Gemeindezentrum 1b, 79790 Küssaberg")
    mock_requests.get.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/geocoding',
        data='{"address": "Gemeindezentrum 1b, 79790 K\\u00fcssaberg"}',
        headers={
            "authorization": f"bearer ABCD",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_error.assert_called_with(
        "Error while sending API call 'get geocoding': 401 unauthorized")
Example #31
0
def test_minimal_post_operation(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_operation(start="2019-06-01T12:00:00", keyword="Brand 2")
    mock_requests.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/operation?updateStrategy=none",
        data='{'
        '"start": "2019-06-01T12:00:00", '
        '"keyword": "Brand 2"}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'post operation' complete")
Example #32
0
def test_error_get_geocoding(mock_requests, mock_error):
    mock_requests.post.return_value.status_code = 401
    mock_requests.post.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.post_passwordcheck(password="******")
    mock_requests.post.assert_called_once_with(
        'https://connectapi.feuersoftware.com/interfaces/public/passwordcheck',
        data='{"password": "******"}',
        headers={
            "authorization": f"bearer ABCD",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_error.assert_called_with(
        "Error while sending API call 'post passwordcheck': 401 unauthorized")
Example #33
0
def test_minimal_post_operation(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_operation(
        start = "2019-06-01T12:00:00",
        keyword = "Brand 2")
    mock_requests.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/operation?updateStrategy=none",
        data='{'
             '"start": "2019-06-01T12:00:00", '
             '"keyword": "Brand 2"}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'post operation' complete")
Example #34
0
def test_minimal_post_news(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.post_news(
        title="Test Title",
        content="Test Content",
        start="2019-06-01T12:00:00",
        end="2019-06-01T18:00:00")
    mock_requests.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news",
        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 'post news' complete")
Example #35
0
def test_full_post_operation(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_operation(start="2019-06-01T12:00:00",
                       end="2019-06-01T14:00:00",
                       keyword="Brand 2",
                       update_strategy="none",
                       status="new",
                       alarmenabled=True,
                       address="Teststrasse 10, 12345 Musterstadt",
                       position={
                           "latitude": "47.592127",
                           "longitude": "8.296870"
                       },
                       facts="Küchenbrand",
                       ric="12B",
                       number=54321,
                       properties=[{
                           "key": "Fettbrand",
                           "value": "Nein"
                       }, {
                           "key": "Noch·Personen·im·Gebäude",
                           "value": "Ja"
                       }])
    mock_requests.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/operation?updateStrategy=none",
        data='{'
        '"start": "2019-06-01T12:00:00", '
        '"keyword": "Brand 2", '
        '"end": "2019-06-01T14:00:00", '
        '"status": "new", '
        '"alarmenabled": true, '
        '"address": "Teststrasse 10, 12345 Musterstadt", '
        '"position": {"latitude": "47.592127", "longitude": "8.296870"}, '
        '"facts": "K\\u00fcchenbrand", '
        '"ric": "12B", '
        '"number": 54321, '
        '"properties": ['
        '{"key": "Fettbrand", "value": "Nein"}, '
        '{"key": "Noch\\u00b7Personen\\u00b7im\\u00b7Geb\\u00e4ude", "value": "Ja"}'
        ']}',
        headers={
            "authorization": f"bearer {TOKEN}",
            "accept": "application/json",
            "content-type": "application/json"
        })
    mock_info.assert_called_with("Success, API call 'post operation' complete")
Example #36
0
def test_minimal_post_news(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 200
    api = PublicAPI(TOKEN)
    api.post_news(title="Test Title",
                  content="Test Content",
                  start="2019-06-01T12:00:00",
                  end="2019-06-01T18:00:00")
    mock_requests.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/news?newsType=siteNews",
        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 'post news' complete")
Example #37
0
def test_invalid_arg_put_news(mock_requests, mock_warning, 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",
        invalid_arg="invalid")
    mock_warning.assert_called_with('Invalid argument passed to put_news: invalid_arg=invalid')
    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")
Example #38
0
def test_invalid_arg_put_news(mock_requests, mock_warning, 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",
                 invalid_arg="invalid")
    mock_warning.assert_called_with(
        'Invalid argument passed to put_news: invalid_arg=invalid')
    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")
Example #39
0
def test_full_post_operation(mock_requests, mock_info):
    mock_requests.post.return_value.status_code = 204
    api = PublicAPI(TOKEN)
    api.post_operation(
        start = "2019-06-01T12:00:00",
        end = "2019-06-01T14:00:00",
        keyword = "Brand 2",
        update_strategy = "none",
        status = "new",
        alarmenabled = True,
        address = "Teststrasse 10, 12345 Musterstadt",
        position = {"latitude":"47.592127", "longitude":"8.296870"},
        facts =  "Küchenbrand",
        ric = "12B",
        number = 54321,
        properties = [
            {"key":"Fettbrand","value":"Nein"},
            {"key":"Noch·Personen·im·Gebäude","value":"Ja"}])
    mock_requests.post.assert_called_once_with(
        f"https://connectapi.feuersoftware.com/interfaces/public/operation?updateStrategy=none",
        data='{'
             '"start": "2019-06-01T12:00:00", '
             '"keyword": "Brand 2", '
             '"end": "2019-06-01T14:00:00", '
             '"status": "new", '
             '"alarmenabled": true, '
             '"address": "Teststrasse 10, 12345 Musterstadt", '
             '"position": {"latitude": "47.592127", "longitude": "8.296870"}, '
             '"facts": "K\\u00fcchenbrand", '
             '"ric": "12B", '
             '"number": 54321, '
             '"properties": ['
                '{"key": "Fettbrand", "value": "Nein"}, '
                '{"key": "Noch\\u00b7Personen\\u00b7im\\u00b7Geb\\u00e4ude", "value": "Ja"}'
             ']}',
        headers={"authorization": f"bearer {TOKEN}",
        "accept": "application/json",
        "content-type": "application/json"})
    mock_info.assert_called_with("Success, API call 'post operation' complete")
Example #40
0
def test_missing_token():
    with pytest.raises(Exception):
        api = PublicAPI()
Example #41
0
def test_error_put_alarmgroup(mock_requests, mock_error):
    mock_requests.put.return_value.status_code = 401
    mock_requests.put.return_value.text = "unauthorized"
    api = PublicAPI(TOKEN)
    api.put_alarmgroup(1, "Test Gruppe", [{"id":1},{"id":2}])
    mock_error.assert_called_with("Error while sending API call 'put alarmgroup': 401 unauthorized")
Example #42
0
def test_error_get_news(mock_requests, mock_error):
    mock_requests.get.return_value.status_code = 401
    mock_requests.get.return_value.text = "unauthorized"
    api = PublicAPI("ABCD")
    api.get_news()
    mock_error.assert_called_with("Error while sending API call 'get news': 401 unauthorized")
Example #43
0
def test_token_set():
    api = PublicAPI(TOKEN)
    assert TOKEN in api._headers["authorization"]