Q3Stats is now open source! :)

This commit is contained in:
2017-03-06 20:33:09 +01:00
commit bfdcb87cef
197 changed files with 16395 additions and 0 deletions

View File

@@ -0,0 +1 @@
spam

Binary file not shown.

View File

@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
import os
from q3stats.testing import BaseQ3StatsWebAppTestCase
class Test_GetFrontendIndex(BaseQ3StatsWebAppTestCase):
@classmethod
def setUpClass(cls):
super(Test_GetFrontendIndex, cls).setUpClass()
cls.app.config['PROPAGATE_EXCEPTIONS'] = False
cls.app.config['LOGGER_HANDLER_POLICY'] = 'never'
def test_404(self):
with self.app.test_request_context():
rsp = self.client.get('/idontexist')
assert rsp.status_code == 404
data = rsp.data.decode('utf-8')
assert 'body id="server-error" class="error-404"' in data
def test_400(self):
with self.app.test_request_context():
rsp = self.client.post('/receivestats')
assert rsp.status_code == 400
data = rsp.data.decode('utf-8')
assert 'body id="server-error" class="error-400"' in data
def test_500(self):
broken_tarball = os.path.join(
os.path.dirname(__file__), 'fixtures', 'broken_tarball.tar'
)
with self.app.test_request_context():
with open(broken_tarball, 'rb') as broken_tarball_f:
rsp = self.client.post('/receivestats', data={
'stats': (broken_tarball_f, 'stats.tar')
})
assert rsp.status_code == 500
data = rsp.data.decode('utf-8')
assert 'body id="server-error" class="error-500"' in data

View File

@@ -0,0 +1,38 @@
# -*- coding: utf -*-
import mock
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
class Test_GetAPIv1ChartsDay(BaseQ3StatsWebAppTestCase):
def test_invalid_day(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/charts/day/spam')
assert rsp.status_code == 400
def test_ok(self):
fake_data = (
['Q3DM7', 'Q3DM17'],
[
{
'data': [30, 30],
'name': 'tomekwojcik'
},
{
'data': [29, 29],
'name': 'Player 1'
}
]
)
with mock.patch.object(views_mod.charts, 'get_day_chart',
return_value=fake_data):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/charts/day/2017-02-15')
assert rsp.status_code == 200
assert rsp.json['day'] == '2017-02-15'
assert rsp.json['maps'] == fake_data[0]
assert rsp.json['scores'] == fake_data[1]

View File

@@ -0,0 +1,38 @@
# -*- coding: utf -*-
import datetime
import mock
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
class Test_GetAPIv1ChartsPlayerAccuracyMap(BaseQ3StatsWebAppTestCase):
def test_ok(self):
fake_data = [
['Q3DM7', 'Q3DM17'],
[
{
'data': [1.23, 4.56],
'name': 'Rocket Launcher'
}
]
]
with mock.patch.object(views_mod.charts,
'get_player_avg_accuracy_chart',
return_value=fake_data):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/tomekwojcik/accuracy/map'
)
assert rsp.status_code == 200
views_mod.charts.get_player_avg_accuracy_chart.\
assert_called_with(
mock.ANY, 'tomekwojcik', agg_by='map'
)
assert rsp.json['maps'] == fake_data[0]
assert rsp.json['series'] == fake_data[1]

View File

@@ -0,0 +1,38 @@
# -*- coding: utf -*-
import datetime
import mock
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
class Test_GetAPIv1ChartsPlayerAccuracySession(BaseQ3StatsWebAppTestCase):
def test_ok(self):
fake_data = [
[datetime.date(2017, 2, 15), datetime.date(2017, 2, 16)],
[
{
'data': [1.23, 4.56],
'name': 'Rocket Launcher'
}
]
]
with mock.patch.object(views_mod.charts,
'get_player_avg_accuracy_chart',
return_value=fake_data):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/tomekwojcik/accuracy/session'
)
assert rsp.status_code == 200
views_mod.charts.get_player_avg_accuracy_chart.\
assert_called_with(
mock.ANY, 'tomekwojcik', agg_by='date'
)
assert rsp.json['dates'] == ['2017-02-15', '2017-02-16']
assert rsp.json['series'] == fake_data[1]

View File

@@ -0,0 +1,102 @@
# -*- coding: utf -*-
import datetime
from q3stats.lib.scripts import utils
from q3stats.models import Game, Score
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
class Test_GetAPIv1ChartsPlayerGame(BaseQ3StatsWebAppTestCase):
@classmethod
def setUpClass(cls):
super(Test_GetAPIv1ChartsPlayerGame, cls).setUpClass()
with utils.db_session(cls._config) as session:
game_dt = datetime.datetime(2017, 2, 15, 20, 21, 0)
game = Game(
uuid='game',
map='Q3DM7',
date=game_dt.date(),
time=game_dt.time(),
fraglimit=20,
attrs={}
)
game.scores.extend([
Score(
player='tomekwojcik',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
Score(
player='Player 1',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
session.add(game)
session.commit()
def test_not_found_player(self):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/%s/game/%s' % ('spam', 'game')
)
assert rsp.status_code == 404
def test_not_found_game(self):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/%s/game/%s' % ('tomekwojcik', 'spam')
)
assert rsp.status_code == 404
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/%s/game/%s' % ('tomekwojcik', 'game')
)
assert rsp.status_code == 200
assert rsp.json['score'] == [
['Frags', 21],
['Deaths', 10],
['Suicides', 1]
]
assert rsp.json['damage'] == [
['Taken', 123],
['Given', 456]
]
assert rsp.json['totals'] == [
['Armor', 456],
['Health', 123]
]

View File

@@ -0,0 +1,33 @@
# -*- coding: utf -*-
import datetime
import mock
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
class Test_GetAPIv1ChartsPlayerWinsSession(BaseQ3StatsWebAppTestCase):
def test_ok(self):
fake_data = [
['Q3DM7', 'Q3DM17'],
[3, 5],
[2, 0]
]
with mock.patch.object(views_mod.charts, 'get_player_wins_chart',
return_value=fake_data):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/tomekwojcik/wins/map'
)
assert rsp.status_code == 200
views_mod.charts.get_player_wins_chart.assert_called_with(
mock.ANY, 'tomekwojcik', agg_by='map'
)
assert rsp.json['maps'] == ['Q3DM7', 'Q3DM17']
assert rsp.json['wins'] == [3, 5]
assert rsp.json['losses'] == [2, 0]

View File

@@ -0,0 +1,33 @@
# -*- coding: utf -*-
import datetime
import mock
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import charts as views_mod
class Test_GetAPIv1ChartsPlayerWinsSession(BaseQ3StatsWebAppTestCase):
def test_ok(self):
fake_data = [
[datetime.date(2017, 2, 15), datetime.date(2017, 2, 16)],
[3, 5],
[2, 0]
]
with mock.patch.object(views_mod.charts, 'get_player_wins_chart',
return_value=fake_data):
with self.app.test_request_context():
rsp = self.client.get(
'/api/v1/charts/player/tomekwojcik/wins/session'
)
assert rsp.status_code == 200
views_mod.charts.get_player_wins_chart.assert_called_with(
mock.ANY, 'tomekwojcik', agg_by='date'
)
assert rsp.json['dates'] == ['2017-02-15', '2017-02-16']
assert rsp.json['wins'] == [3, 5]
assert rsp.json['losses'] == [2, 0]

View File

@@ -0,0 +1,52 @@
# -*- coding: utf -*-
import datetime
import mock
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import dashboard as views_mod
class Test_GetAPIv1Dashboard(BaseQ3StatsWebAppTestCase):
def test_ok(self):
fake_days = [datetime.date(2017, 2, 16), datetime.date(2017, 2, 15)]
fake_fotm = [
['tomekwojcik', 20],
['Player 1', 10]
]
fake_eotm = [
['Player 1', 20],
['tomekwojcik', 10]
]
def fake_get_top_players(session, agg_by='kills'):
if agg_by == 'suicides':
return fake_eotm
return fake_fotm
with mock.patch.object(views_mod.queries, 'get_game_dates',
return_value=fake_days):
with mock.patch.object(views_mod.queries, 'get_top_players',
side_effect=fake_get_top_players):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/dashboard')
assert rsp.status_code == 200
views_mod.queries.get_game_dates.assert_called_with(
mock.ANY
)
views_mod.queries.get_top_players.assert_any_call(
mock.ANY
)
views_mod.queries.get_top_players.assert_any_call(
mock.ANY, agg_by='suicides'
)
assert rsp.json['day'] == '2017-02-16'
assert rsp.json['fotm'] == fake_fotm
assert rsp.json['eotm'] == fake_eotm

View File

@@ -0,0 +1,103 @@
# -*- coding: utf -*-
import datetime
from q3stats.lib.scripts import utils
from q3stats.models import Game, Score
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import players as views_mod
class Test_GetAPIv1Players(BaseQ3StatsWebAppTestCase):
@classmethod
def setUpClass(cls):
super(Test_GetAPIv1Players, cls).setUpClass()
with utils.db_session(cls._config) as session:
game1_dt = datetime.datetime(2017, 2, 21, 18, 30)
game1 = Game(
uuid='game1',
map='Q3DM7',
date=game1_dt.date(),
time=game1_dt.time(),
fraglimit=20,
attrs={}
)
game1.scores.extend([
Score(
player='Player 1',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={
'RL': {
'hits': 10,
'kills': 5,
'shots': 20
}
},
items={
'YA': 1
},
powerups={
'Quad': [3, 40000]
}
),
Score(
player='Player 2',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
session.add(game1)
session.commit()
def test_not_found_game(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/players/Player 1/game/spam')
assert rsp.status_code == 404
def test_not_found_player(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/players/spam/game/game1')
assert rsp.status_code == 404
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/players/Player 1/game/game1')
assert rsp.status_code == 200
assert rsp.json['map'] == 'Q3DM7'
assert rsp.json['items'] == {'YA': 1}
assert rsp.json['weapons'] == {
'RL': {
'hits': 10,
'kills': 5,
'shots': 20,
'accuracy': '50.00%'
}
}
assert rsp.json['powerups'] == {
'Quad': [3, '40.000']
}

View File

@@ -0,0 +1,113 @@
# -*- coding: utf -*-
import datetime
from q3stats.lib.scripts import utils
from q3stats.models import Game, Score
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import players as views_mod
class Test_GetAPIv1Players(BaseQ3StatsWebAppTestCase):
@classmethod
def setUpClass(cls):
super(Test_GetAPIv1Players, cls).setUpClass()
with utils.db_session(cls._config) as session:
game1_dt = datetime.datetime(2017, 2, 21, 18, 30)
game1 = Game(
uuid='game1',
map='Q3DM7',
date=game1_dt.date(),
time=game1_dt.time(),
fraglimit=20,
attrs={}
)
game1.scores.extend([
Score(
player='Player 1',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
Score(
player='Player 2',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
game2_dt = datetime.datetime(2017, 2, 21, 18, 31)
game2 = Game(
uuid='game2',
map='Q3DM17',
date=game2_dt.date(),
time=game2_dt.time(),
fraglimit=20,
attrs={}
)
game2.scores.extend([
Score(
player='Player 1',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
Score(
player='Player 3',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
session.add_all([game1, game2])
session.commit()
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/players/')
assert rsp.status_code == 200
assert rsp.json['players'] == ['Player 1', 'Player 2', 'Player 3']

View File

@@ -0,0 +1,261 @@
# -*- coding: utf -*-
import datetime
from q3stats.lib.scripts import utils
from q3stats.models import Game, Score
from q3stats.testing import BaseQ3StatsWebAppTestCase
from q3stats.web_app.blueprints.api_v1.views import players as views_mod
class Test_GetAPIv1Session(BaseQ3StatsWebAppTestCase):
@classmethod
def setUpClass(cls):
super(Test_GetAPIv1Session, cls).setUpClass()
with utils.db_session(cls._config) as session:
game1_dt = datetime.datetime(2017, 2, 20, 18, 30)
game1 = Game(
uuid='game1',
map='Q3DM7',
date=game1_dt.date(),
time=game1_dt.time(),
fraglimit=20,
attrs={}
)
game1.scores.extend([
Score(
player='Player 1',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
Score(
player='Player 2',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
game2_dt = datetime.datetime(2017, 2, 21, 18, 31)
game2 = Game(
uuid='game2',
map='Q3DM17',
date=game2_dt.date(),
time=game2_dt.time(),
fraglimit=20,
attrs={}
)
game2.scores.extend([
Score(
player='Player 1',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={
'RL': {
'hits': 10,
'kills': 4,
'shots': 20
},
'RG': {
'hits': 10,
'kills': 5,
'shots': 20
}
},
items={},
powerups={
'Quad': [3, 12345]
}
),
Score(
player='Player 3',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={
'Quad': [2, 12345]
}
),
])
game3_dt = datetime.datetime(2017, 2, 21, 18, 32)
game3 = Game(
uuid='game3',
map='Q3DM17',
date=game3_dt.date(),
time=game3_dt.time(),
fraglimit=20,
attrs={}
)
game3.scores.extend([
Score(
player='Player 1',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
Score(
player='Player 3',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
game4_dt = datetime.datetime(2017, 2, 22, 18, 31)
game4 = Game(
uuid='game4',
map='Q3DM17',
date=game4_dt.date(),
time=game4_dt.time(),
fraglimit=20,
attrs={}
)
game4.scores.extend([
Score(
player='Player 2',
score=20,
kills=21,
deaths=10,
suicides=1,
net=11,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
Score(
player='Player 3',
score=10,
kills=11,
deaths=20,
suicides=1,
net=10,
damage_taken=123,
damage_given=456,
total_health=123,
total_armor=456,
weapons={},
items={},
powerups={}
),
])
session.add_all([game1, game2, game3, game4])
session.commit()
def test_invalid_day(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/sessions/spam')
assert rsp.status_code == 400
def test_not_found(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/sessions/1985-12-12')
assert rsp.status_code == 404
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/sessions/2017-02-21')
assert rsp.status_code == 200
assert rsp.json['day'] == '2017-02-21'
assert rsp.json['previous_day'] == '2017-02-20'
assert rsp.json['next_day'] == '2017-02-22'
assert len(rsp.json['games']) == 2
game = rsp.json['games'][0]
assert game['uuid'] == 'game2'
assert game['map'] == 'Q3DM17'
assert len(game['scores']) == 2
score1 = game['scores'][0]
assert score1['player'] == 'Player 1'
assert score1['score'] == 20
assert score1['kills'] == 21
assert score1['deaths'] == 10
assert score1['suicides'] == 1
assert score1['favourite_weapon'] == 'RG'
assert score1['quad_freak'] is True
assert score1['quad_pickups'] == 3
score2 = game['scores'][1]
assert score2['favourite_weapon'] is None
assert score2['quad_freak'] is False
assert score2['quad_pickups'] == 0
def test_ok_no_previous_day(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/sessions/2017-02-20')
assert rsp.status_code == 200
assert rsp.json['previous_day'] is None
def test_ok_no_next_day(self):
with self.app.test_request_context():
rsp = self.client.get('/api/v1/sessions/2017-02-22')
assert rsp.status_code == 200
assert rsp.json['next_day'] is None

View File

@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
from q3stats.testing import BaseQ3StatsWebAppTestCase
class Test_GetFrontendIndex(BaseQ3StatsWebAppTestCase):
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/')
assert rsp.status_code == 200

View File

@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
from q3stats.testing import BaseQ3StatsWebAppTestCase
class Test_GetFrontendPlayerGame(BaseQ3StatsWebAppTestCase):
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/players/tomekwojcik/game/spam')
assert rsp.status_code == 302
assert rsp.headers['Location'].endswith(
'/#/players/tomekwojcik/game/spam'
)

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from q3stats.testing import BaseQ3StatsWebAppTestCase
class Test_GetFrontendPlayers(BaseQ3StatsWebAppTestCase):
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/players/')
assert rsp.status_code == 302
assert rsp.headers['Location'].endswith('/#/players/')
def test_ok_with_player(self):
with self.app.test_request_context():
rsp = self.client.get('/players/tomekwojcik')
assert rsp.status_code == 302
assert rsp.headers['Location'].endswith('/#/players/tomekwojcik')

View File

@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
from q3stats.testing import BaseQ3StatsWebAppTestCase
class Test_GetFrontendSessions(BaseQ3StatsWebAppTestCase):
def test_ok(self):
with self.app.test_request_context():
rsp = self.client.get('/sessions/')
assert rsp.status_code == 302
assert rsp.headers['Location'].endswith('/#/sessions/')
def test_ok_with_day(self):
with self.app.test_request_context():
rsp = self.client.get('/sessions/2017-02-14')
assert rsp.status_code == 302
assert rsp.headers['Location'].endswith('/#/sessions/2017-02-14')

View File

@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*-
import os
import shutil
import tempfile
import mock
import six
from q3stats.web_app.blueprints.frontend import views as views_module
from q3stats.testing import BaseQ3StatsWebAppTestCase
class Test_PostFrontendReceivestats(BaseQ3StatsWebAppTestCase):
def setUp(self):
self._tmp_path = tempfile.mkdtemp(dir=os.path.abspath(
os.path.join(os.path.dirname(__file__), 'tmp')
))
self._fixtures_path = os.path.join(
os.path.dirname(__file__), 'fixtures'
)
def tearDown(self):
shutil.rmtree(self._tmp_path)
def test_get(self):
with self.app.test_request_context():
rsp = self.client.get('/receivestats')
assert rsp.status_code == 405
def test_missing_stats_file(self):
with self.app.test_request_context():
with mock.patch.object(views_module, 'importer'):
rsp = self.client.post('/receivestats')
assert rsp.status_code == 400
assert not views_module.importer.called
def test_bad_stats_file(self):
self.app.config['PROPAGATE_EXCEPTIONS'] = False
self.app.config['LOGGER_HANDLER_POLICY'] = 'never'
broken_tarball_path = os.path.join(
self._fixtures_path, 'broken_tarball.tar'
)
broken_tarball_f = open(broken_tarball_path, 'rb')
with mock.patch.object(views_module.tempfile, 'mkdtemp',
return_value=self._tmp_path):
with mock.patch.object(views_module, 'importer'):
with mock.patch.object(views_module.shutil, 'rmtree'):
with self.app.test_request_context():
rsp = self.client.post('/receivestats', data={
'stats': (broken_tarball_f, 'stats.tar')
})
assert rsp.status_code == 500
assert not views_module.importer.called
views_module.shutil.rmtree.assert_called_with(
self._tmp_path
)
broken_tarball_f.close()
self.app.config.pop('PROPAGATE_EXCEPTIONS')
self.app.config.pop('LOGGER_HANDLER_POLICY')
def test_ok(self):
stats_path = os.path.join(self._fixtures_path, 'stats.tar')
stats_f = open(stats_path, 'rb')
with mock.patch.object(views_module.tempfile, 'mkdtemp',
return_value=self._tmp_path):
with mock.patch.object(views_module, 'importer'):
with mock.patch.object(views_module.shutil, 'rmtree'):
with self.app.test_request_context():
rsp = self.client.post('/receivestats', data={
'stats': (stats_f, 'stats.tar')
})
assert rsp.status_code == 200
assert views_module.tempfile.mkdtemp.called
assert os.path.isfile(
os.path.join(self._tmp_path, 'game.xml')
)
views_module.importer.assert_called_with(
[self._tmp_path], self.app.config
)
views_module.shutil.rmtree.assert_called_with(
self._tmp_path
)
stats_f.close()