Skip to content

Commit

Permalink
test color stats plot
Browse files Browse the repository at this point in the history
  • Loading branch information
guidopetri committed May 11, 2021
1 parent eac7e7f commit 240b9dd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/test_plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /usr/bin/env python3

from pipeline_import import plots
import pandas as pd
import os
import hashlib


def test_color_stats_plot():

multiindex = pd.MultiIndex.from_arrays([['blitz', 'blitz', 'bullet'],
['white', 'black', 'black']],
names=('time_control_category',
'player_color'))

color_stats = pd.DataFrame([[1 / 3, 1 / 3, 1 / 3],
[1, 0, 0],
[1, 0, 0]],
columns=['Win', 'Draw', 'Loss'],
index=multiindex,
)

fig_loc = '.'
filename = 'color_stats_test.png'

plots.make_color_stats_plot(color_stats, fig_loc, filename)

file_loc = os.path.join(fig_loc, filename)

with open(file_loc, 'rb') as f:
md5 = hashlib.md5(f.read()).hexdigest()

true_md5 = '07fbf16c92a2544669f404e17db3e5b9'

assert md5 == true_md5

os.remove(file_loc)

0 comments on commit 240b9dd

Please sign in to comment.