Skip to content

Commit

Permalink
fix: NoneType error on JSON output without position
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Deuchnord committed Aug 26, 2021
1 parent cbc5f6a commit a406b9d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .scripts/tests-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-0
assertSuccess "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=json"
assertFailure "$KOSMORRO_COMMAND --latitude=50.5876 --longitude=3.0624 -d 2020-01-27 --format=pdf"

assertSuccess "$KOSMORRO_COMMAND -d 2020-01-27 --format=json"

# Environment variables
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=1 kosmorro -d 2020-01-27"
assertSuccess "LATITUDE=50.5876 LONGITUDE=3.0624 TIMEZONE=-1 kosmorro -d 2020-01-27"
Expand Down
24 changes: 16 additions & 8 deletions _kosmorro/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,23 @@


class Dumper(ABC):
ephemerides: [AsterEphemerides]
moon_phase: MoonPhase
events: [Event]
date: datetime.date
timezone: int
with_colors: bool
show_graph: bool

def __init__(
self,
ephemerides: [AsterEphemerides] = None,
moon_phase: MoonPhase = None,
events: [Event] = None,
date: datetime.date = datetime.date.today(),
timezone: int = 0,
with_colors: bool = True,
show_graph: bool = False,
ephemerides: [AsterEphemerides],
moon_phase: MoonPhase,
events: [Event],
date: datetime.date,
timezone: int,
with_colors: bool,
show_graph: bool,
):
self.ephemerides = ephemerides
self.moon_phase = moon_phase
Expand Down Expand Up @@ -99,7 +107,7 @@ class TextDumper(Dumper):
def to_string(self):
text = [self.style(self.get_date_as_string(capitalized=True), "h1")]

if self.ephemerides is not None:
if len(self.ephemerides) > 0:
text.append(self.stringify_ephemerides())

text.append(self.get_moon(self.moon_phase))
Expand Down
2 changes: 1 addition & 1 deletion _kosmorro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_information(
except OutOfRangeDateError as error:
raise DateRangeError(error.min_date, error.max_date)
else:
eph = None
eph = []

try:
moon_phase = get_moon_phase(compute_date)
Expand Down
Empty file removed test/events.py
Empty file.

0 comments on commit a406b9d

Please sign in to comment.