Skip to content

Commit

Permalink
Actual unit tests
Browse files Browse the repository at this point in the history
	modified:   obstools/tests/test_deveny_grangle.py
  • Loading branch information
tbowers7 committed Nov 5, 2024
1 parent 9cbb94b commit 55a863d
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions obstools/tests/test_deveny_grangle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-function-docstring
# -*- coding: utf-8 -*-
#
# This file is part of LDTObserverTools.
Expand All @@ -13,27 +14,51 @@
"""DeVeny Grating Angle Calculator TEST Module
"""

import pytest
import numpy as np

def test_deveny_grangle_cli():
assert 1 == 1
from obstools import deveny_grangle


def test_deveny_grangle_gui():
assert 1 == 1
# NOTE: No unit tests for deveny_grangle_cli() and deveny_grangle_gui()
# functions. Need to find another way to test those.


def test_compute_grangle():
assert 1 == 1
grangle, amag = deveny_grangle.compute_grangle(400, 8000)
# Ensure returns are floats and the correct values
assert isinstance(grangle, float)
assert isinstance(amag, float)
assert np.isclose(grangle, 27.8919, atol=1.0e-4)
assert np.isclose(amag, 0.8257, atol=1.0e-4)


def test_grangle_eqn():
assert 1 == 1
zero = deveny_grangle.grangle_eqn(np.deg2rad(22.54), 300, 5195)
# Ensure zero is a float and of the correct value
assert isinstance(zero, float)
assert np.isclose(zero, 0, atol=1)
# Check another grating
zero = deveny_grangle.grangle_eqn(np.deg2rad(21.00), 150, 7220)
assert np.isclose(zero, 0, atol=1)


def test_lambda_at_angle():
assert 1 == 1
cenwave = deveny_grangle.lambda_at_angle(22.54, 300)
# Ensure cenwave is a float and of the correct value
assert isinstance(cenwave, float)
assert np.isclose(cenwave, 5195, atol=1)
# Check another grating
cenwave = deveny_grangle.lambda_at_angle(25.60, 500)
assert np.isclose(cenwave, 5000, atol=1)
# Test the radians option
cenwave = deveny_grangle.lambda_at_angle(np.deg2rad(40.96), 831, radians=True)
assert np.isclose(cenwave, 8499, atol=1)


def test_deveny_amag():
assert 1 == 1
amag = deveny_grangle.deveny_amag(22.54)
# Ensure amag is a float of the correct value
assert isinstance(amag, float)
assert np.isclose(amag, 0.9122, atol=1.0e-4)
# Check another value
amag = deveny_grangle.deveny_amag(27.04)
assert np.isclose(amag, 0.8391, atol=1.0e-4)

0 comments on commit 55a863d

Please sign in to comment.