From 1cc0453df2ba30a8f751ddfee7aaab922b900052 Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Fri, 2 Feb 2024 18:04:16 -0800 Subject: [PATCH] Added tests and documentation for updated add_filepath(). --- docs/4-data.md | 2 +- docs/5-settings.md | 2 ++ tests/test_setup.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/4-data.md b/docs/4-data.md index d7f2015..710c302 100644 --- a/docs/4-data.md +++ b/docs/4-data.md @@ -597,7 +597,7 @@ You are free to use the actual numerical index for these objects, but of course Immanuel indexes chart objects numerically rather than by name for two main reasons: -* Avoid name conflicts (eg. the three Liliths). +* Avoid name conflicts (eg. the four Liliths). * Allow external objects to be easily added from your own extra ephemeris files by their default index. To demonstrate, asteroid Lilith is number 1181 as designated by the International Astronomical Union. This is the number of the ephemeris file you would need for Immanuel to include it, and on astro.com this is the number you would type into the "Manual entry" box under "Additional objects" to include the asteroid in your chart. diff --git a/docs/5-settings.md b/docs/5-settings.md index 953d0f8..b6cacfb 100644 --- a/docs/5-settings.md +++ b/docs/5-settings.md @@ -652,6 +652,8 @@ This will return a standard asteroid object: Congratulations - you have imported an external object into your chart. +If you want Immanuel to only use your own ephemeris files for everything, passing `True` as a second parameter to `add_filepath()` will set the passed path as the only path rather than adding it to the default one. + --- 1. [Overview](1-overview.md) diff --git a/tests/test_setup.py b/tests/test_setup.py index f80710d..5d81d0a 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -9,6 +9,11 @@ """ +import os +from datetime import datetime + +import swisseph as swe +import pytest from pytest import fixture from immanuel import charts @@ -83,3 +88,17 @@ def test_settings_are_respected(native): natal = charts.Natal(native) assert chart.SUN not in natal.aspects + + +def test_add_filepath(native): + settings.add_filepath(os.path.dirname(__file__)) + settings.objects.append(1181) + natal = charts.Natal(native) + assert 1181 in natal.objects + + # Cache-bust + settings.add_filepath(os.path.dirname(__file__), True) + native2 = charts.Subject(datetime.now(), '32N43.0', '117W9.0') + + with pytest.raises(swe.Error): + charts.Natal(native2)