コード例 #1
0
def test_send_reminder():
    send_reminder()
    mock = get_mock("alt_side_parking.sms.get_client")
    mock().api.account.messages.create.assert_called_with(
        to="+13472344323",
        from_="+12123452342",
        body="Move your car my guy",
    )
コード例 #2
0
ファイル: test_utils.py プロジェクト: salah93/adhan-pi
def test_get_location():
    location = utils.get_location_from_query("New York, NY")
    assert (0, 1) == tuple(location)
    assert location.latitude == 0
    assert location.longitude == 1
    mock = get_mock("adhan_pi.utils.Nominatim")
    mock.assert_called_with(user_agent="adhan-pi")
    mock().geocode.assert_called_with("New York, NY")
コード例 #3
0
def test_import_package_resource():
    package = {
        'type': 'dataset',
        'id': 1,
        'resources': [simple_resource],
        'tags': [],
        'groups': []
    }
    importer.import_package(package)
    mocked = automock.get_mock('opendata.importer.insert_or_update')
    assert mocked.call_count == 2
コード例 #4
0
def test_schedule_no_previous_jobs(prayer_api_200_response, cache_folder):
    cli.schedule_prayer_cron("salah", "Los Angeles", cache_folder)
    pwd_mock = get_mock("adhan_pi.cli.pwd")
    pwd_mock.getpwnam.assert_called_with("salah")
    geopy_mock = get_mock("adhan_pi.utils.Nominatim")
    geopy_mock.assert_called_with(user_agent="adhan-pi")
    geopy_mock().geocode.assert_called_with("Los Angeles")
    cron_mock = get_mock("adhan_pi.cli.CronTab")
    cron_mock.assert_called_with(user="******")
    cron_mock().__enter__().find_comment.assert_called_with("adhan_pi")
    cron_mock().__enter__().remove.assert_not_called()
    for p in ["fajr", "dhuhr", "asr", "maghrib", "isha"]:
        cron_mock().__enter__().new.assert_any_call(
            command=
            "XDG_RUNTIME_DIR=/run/user/{user_id} /opt/adhan-pi/env/bin/alert_adhan --prayer {prayer} > /dev/null 2>&1"
            .format(
                user_id=1000,
                prayer=p,
            ),
            comment="adhan_pi",
        )
コード例 #5
0
def test_alert_adhan():
    cli.AdhanAlertFFMPEG("dhuhr").alert()
    audio_mock = get_mock("adhan_pi.cli.AudioSegment")
    play_mock = get_mock("adhan_pi.cli.play")
    audio_mock.from_mp3.assert_called_with("adhan.mp3")
    play_mock.assert_called_with(audio_mock.from_mp3())
コード例 #6
0
def test_import_package_simple():
    importer.import_package(simple_package)
    mocked = automock.get_mock('opendata.importer.insert_or_update')
    assert mocked.call_count == 1
    mocked.assert_called_once_with('package', simple_package, 'id',
                                   importer.exclude_package)