def test_clean_json():
    """are the json files empty after calling the method"""
    add_data_to_json(
        "notification", {
            "title": "Spotify artist pages hacked by Taylor Swift 'fan'",
            "content": "An apparent Taylor Swift..."
        })
    clean_json("notification")
    assert get_list_from_json("notification") == []
def test_add_notification_to_json():
    """does the notification data save properly and is read properly?"""
    clean_json("notification")
    add_data_to_json(
        "notification", {
            "title": "Spotify artist pages hacked by Taylor Swift 'fan'",
            "content": "An apparent Taylor Swift..."
        })
    assert [{
        'title': "Spotify artist pages hacked by Taylor Swift 'fan'",
        'content': 'An apparent Taylor Swift...'
    }] == get_list_from_json("notification")
def test_process_user_input():
    """test if the input data is saved properly as an alarm"""
    clean_json("alarm")
    process_user_input("2021-01-04T13:18", "xyz", "news", "weather")
    print(get_list_from_json("alarm"))
    assert get_list_from_json("alarm") == [{
        'date': '2021-01-04',
        'time': '13:18:00',
        'title': 'xyz',
        'content': 'alarm set for 2021-01-04 at 13:18:00',
        'news': True,
        'weather': True
    }]
def test_add_alarm_to_json():
    """does the alarm data save properly and is read properly?"""
    clean_json("alarm")
    add_data_to_json(
        "alarm", {
            "date": "2020-12-04",
            "time": "13:18:00",
            "title": "xyz",
            "content": "alarm set for 2020-12-04 at 13:18:00",
            "news": True,
            "weather": False
        })
    assert get_list_from_json("alarm") == [{
        "date": "2020-12-04",
        "time": "13:18:00",
        "title": "xyz",
        "content": "alarm set for 2020-12-04 at 13:18:00",
        "news": True,
        "weather": False
    }]
def test_delete_from_json():
    """Is the data deleted properly from the alarms_data.json"""
    clean_json("alarm")
    add_data_to_json(
        "alarm", {
            "date": "2020-12-04",
            "time": "13:18:00",
            "title": "xyz",
            "content": "alarm set for 2020-12-04 at 13:18:00",
            "news": True,
            "weather": False
        })
    add_data_to_json(
        "alarm", {
            "date": "2020-12-04",
            "time": "13:19:00",
            "title": "abc",
            "content": "alarm set for 2020-12-04 at 13:18:00",
            "news": True,
            "weather": False
        })
    delete_from_json(
        "alarm", {
            "date": "2020-12-04",
            "time": "13:18:00",
            "title": "xyz",
            "content": "alarm set for 2020-12-04 at 13:18:00",
            "news": True,
            "weather": False
        })
    assert get_list_from_json("alarm") == [{
        "date": "2020-12-04",
        "time": "13:19:00",
        "title": "abc",
        "content": "alarm set for 2020-12-04 at 13:18:00",
        "news": True,
        "weather": False
    }]