Пример #1
0
def test_alarm_invalid_coordinates(requests_mock, logs):
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text="token")
    requests_mock.post("https://fireplanapi.azurewebsites.net/api/Alarmierung",
                       text="200")
    fp = fireplan.Fireplan("secret", "division")
    r = fp.alarm({"koordinaten": "55,23 , 45,56"})
    assert r == True
    assert requests_mock.call_count == 2
    assert requests_mock.last_request.json() == {
        "alarmtext": "",
        "einsatznrlst": "",
        "strasse": "",
        "hausnummer": "",
        "ort": "",
        "ortsteil": "",
        "objektname": "",
        "koordinaten": "",
        "einsatzstichwort": "",
        "zusatzinfo": "",
        "sonstiges1": "",
        "sonstiges2": "",
        "RIC": "",
        "SubRIC": "",
    }
Пример #2
0
def test_alarm_api_error(requests_mock):
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text="token")
    requests_mock.post("https://fireplanapi.azurewebsites.net/api/Alarmierung",
                       text="400")
    fp = fireplan.Fireplan("secret", "division")
    assert fp.alarm({}) == False
    assert requests_mock.call_count == 2
Пример #3
0
def test_status_empty_data(requests_mock):
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text="token")
    requests_mock.put("https://fireplanapi.azurewebsites.net/api/FMS",
                      text="200")
    fp = fireplan.Fireplan("secret", "division")
    assert fp.status({}) == None
    assert requests_mock.call_count == 1
Пример #4
0
def test_status_invalid_data_type(requests_mock, logs):
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text="token")
    requests_mock.put("https://fireplanapi.azurewebsites.net/api/FMS",
                      text="200")
    fp = fireplan.Fireplan("secret", "division")
    assert fp.status({"Status": 12}) == None
    assert requests_mock.call_count == 1
Пример #5
0
def test_init(requests_mock):
    secret = "BA4568A-F5A89EF"
    division = "Musterhausen"
    token = "eyJhbGciOiJodHRwOi8vd3d3pnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJDWFNlY3JldC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npVRFlCZVZ4YmtDT3lpODE3aFJHQ3lKeFU4cjFCRmVkQ1JOMmlUQ09WWWs2Mk5oaGdhd25BPT0iLCJFeHBpcmVzIjo2Nzc1NDgwNTYxOTI4NDU3MTh9.3PKeYh1gknE707eCXA1kpgv3cuaSXm6YAER8EklGW5E"
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text=token)
    fp = fireplan.Fireplan(secret, division)
    assert requests_mock.called == True
    assert fp.headers["utoken"] == token
Пример #6
0
def test_status_valid_data(requests_mock):
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text="token")
    requests_mock.put("https://fireplanapi.azurewebsites.net/api/FMS",
                      text="200")
    fp = fireplan.Fireplan("secret", "division")
    data = {"FZKennung": "40225588996", "Status": "3"}
    assert fp.status(data) == True
    assert requests_mock.call_count == 2
    assert requests_mock.last_request.json() == data
Пример #7
0
def test_alarm_valid_data(requests_mock):
    requests_mock.get("https://fireplanapi.azurewebsites.net/api/registerV2",
                      text="token")
    requests_mock.post("https://fireplanapi.azurewebsites.net/api/Alarmierung",
                       text="200")
    fp = fireplan.Fireplan("secret", "division")
    data = {
        "alarmtext": "Brand 3 –Brand im Wohnhaus",
        "einsatznrlst": "321123",
        "strasse": "Walter-Gropuius-Strasse",
        "hausnummer": "3",
        "ort": "München",
        "ortsteil": "Schwabing",
        "objektname": "Gebäude Kantine",
        "koordinaten": "51.3344,-5.22223",
        "einsatzstichwort": "Brand 5",
        "zusatzinfo": "Brandmeldeanlage",
        "sonstiges1": "sonstige1",
        "sonstiges2": "sonstige2",
        "RIC": "40001",
        "SubRIC": "A",
    }
    assert fp.alarm(data) == True
    assert requests_mock.call_count == 2
    assert requests_mock.last_request.json() == {
        "alarmtext": "Brand 3 –Brand im Wohnhaus",
        "einsatznrlst": "321123",
        "strasse": "Walter-Gropuius-Strasse",
        "hausnummer": "3",
        "ort": "München",
        "ortsteil": "Schwabing",
        "objektname": "Gebäude Kantine",
        "koordinaten": "51.3344,-5.22223",
        "einsatzstichwort": "Brand 5",
        "zusatzinfo": "Brandmeldeanlage",
        "sonstiges1": "sonstige1",
        "sonstiges2": "sonstige2",
        "RIC": "40001",
        "SubRIC": "A",
    }