Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tests for plotter #141

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/test_plotter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from pytentiostat.plotter import plot_initializer, plot_updater
import pytentiostat.config_reader as cr
import os
import mock

THIS_DIR = os.path.dirname(os.path.abspath(__file__))


def test_plot_initializer():
confdir = os.path.join(THIS_DIR, 'static/')
config_data = cr.parse_config_file(confdir)
with mock.patch("my.module.plt.show") as show_patch:
line = plot_initializer(config_data)
assert show_patch.called
xlow, xhigh = line.get_xlim()
print (xlow)
ylow, yhigh = line.get_ylim()
assert xlow == -2.5
assert xhigh == 2.5
assert ylow == -2.5
assert yhigh == 2.5
xlabel = line.xaxis.get_label()
ylabel = line.yaxis.get_label()
assert xlabel == "Voltage (V)"
assert ylabel == "Current (mA)"

def test_plot_updater():
confdir = os.path.join(THIS_DIR, 'static/')
config_data = cr.parse_config_file(confdir)
with mock.patch("my.module.plt.show") as show_patch:
line = plot_initializer(config_data)
data = (0, 0, 0)
plot_updater(config_data, data, line)
assert show_patch.called
xlow, xhigh = line.get_xlim()
print(xlow)
ylow, yhigh = line.get_ylim()
assert xlow == -2.5
assert xhigh == 2.5
assert ylow == -2.5
assert yhigh == 2.5
xlabel = line.xaxis.get_label()
ylabel = line.yaxis.get_label()
assert xlabel == "Voltage (V)"
assert ylabel == "Current (mA)"