File: test_shadow.py

package info (click to toggle)
einsteinpy 0.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,712 kB
  • sloc: python: 8,196; makefile: 146
file content (35 lines) | stat: -rw-r--r-- 910 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from unittest import mock

import pytest
from astropy import units as u
from matplotlib import pyplot as plt

from einsteinpy.plotting import ShadowPlotter
from einsteinpy.rays import Shadow


@pytest.fixture()
def dummy_data():
    mass = 1 * u.kg
    fov = 30 * u.km
    shadow = Shadow(mass=mass, fov=fov, n_rays=1000)
    return shadow


def test_plotter_has_correct_attributes(dummy_data):
    shadow = dummy_data
    cl = ShadowPlotter(shadow=shadow)
    assert isinstance(cl.shadow, Shadow)
    assert cl.is_intensity_plot


@mock.patch("einsteinpy.plotting.rays.shadow.plt.plot")
def test_plot_calls_plt_plot(mock_patch, dummy_data):
    shadow = dummy_data
    cl = ShadowPlotter(shadow=shadow)
    cl.plot()
    expected = [
        mock.call(cl.shadow.fb1, cl.shadow.intensity, "r"),
        mock.call(cl.shadow.fb2, cl.shadow.intensity, "r"),
    ]
    assert mock_patch.call_args_list == expected