def test_abs_magnitude_graph_missing_neo_names_returns_exception(): """Test if absolute magnitude graph's raises exception, missing neo names arg.""" from space_rocks.views.plot_magnitude import graph_abs_magnitude test_mag = [1, 2, 3, 4, 5] test_vel = [2, 5, 8, 2, 7] with pytest.raises(UnknownAxisException): graph_abs_magnitude(test_mag, test_vel, [])
def test_abs_magnitude_graph_missing_velocity_returns_exception(): """Test if absolute magnitude graph's raises exception, missing velocity arg.""" from space_rocks.views.plot_magnitude import graph_abs_magnitude test_mag = [1, 2, 3, 4, 5] test_neo_names = [ "ceres", "phobos", "deimos", "asteroid x", "it was earth all along!!" ] with pytest.raises(UnknownAxisException): graph_abs_magnitude(test_mag, [], test_neo_names)
def test_abs_magnitude_graph_exists_valid_arguments(): """Test if absolute magnitude scatter plot is generated with arguments passed.""" from space_rocks.views.plot_magnitude import graph_abs_magnitude test_mag = [1, 2, 3, 4, 5] test_vel = [2, 5, 8, 2, 7] test_neo_names = [ "ceres", "phobos", "deimos", "asteroid x", "it was earth all along!!" ] graph_abs_magnitude(test_mag, test_vel, test_neo_names) assert os.path.isfile("static/graphs/abs_magnitude.html")
def absolute_magnitude_view(request): """Render the view for absolute mignitude.""" from space_rocks.views.plot_magnitude import graph_abs_magnitude mag_data = request.dbsession.query(AbsoluteMag).all() mag_axis = [] vel_axis = [] neo_names = [] for i in range(len(mag_data)): mag_axis.append(mag_data[i].absolutemag) vel_axis.append(mag_data[i].velocity_kps) neo_names.append(mag_data[i].neo_id) graph_abs_magnitude(mag_axis, vel_axis, neo_names) return {}
def test_abs_magnitude_graph_empty_arguments_returns_exception(): """Test if absolute magnitude graph's raises exception, empty args.""" from space_rocks.views.plot_magnitude import graph_abs_magnitude with pytest.raises(UnknownAxisException): graph_abs_magnitude([], [], [])