blob: c804742621458df8b39d3ed87d482fe99a24cc94 (
plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
import unittest
import os
import shutil
import glob
from CeibalEncuesta import CeibalEncuesta
WORKPATH = 'test_files'
TEMPPATH = os.path.join(WORKPATH, "fixture_enc_simple.encuesta")
class MockDialog(object):
def run(self):
pass
def destroy(self):
pass
class MockPanel(object):
def __init__(self):
self.encuestados = 'dadsa'
self.encuesta = 'blah'
class MockInfoWidget(object):
def get_info(self):
return {'poll_name': 'test_poll'}
class MockCeibalEncuesta(CeibalEncuesta):
def __init__(self, fixture):
self.panel = MockPanel()
self.infowidget = MockInfoWidget()
self._CeibalEncuesta__save_json = self._save_json
self.path = TEMPPATH
self.backup_path = os.path.join(WORKPATH, fixture)
def _save_json(self, path=None):
return ''
def _alert_dialog(self, parent_window, label):
return MockDialog()
class NoBorraTempAlExportarTest(unittest.TestCase):
"""Este test hace referencia al issue #4143"""
def setUp(self):
self.fixture_tmp = 'fixture_tmp.encuesta'
def test_exporta_y_no_borra_temp(self):
fixture = 'fixture_enc_simple.encuesta'
fixture_tmp_full = WORKPATH + '/' + self.fixture_tmp
shutil.copy2(WORKPATH + '/' + fixture, fixture_tmp_full)
ce = MockCeibalEncuesta(self.fixture_tmp)
ce._CeibalEncuesta__save_results(widget=None, chosen_path=WORKPATH)
self.assertTrue(os.path.exists(fixture_tmp_full))
def tearDown(self):
for f in glob.glob(WORKPATH + '/' + '*.poll_result'):
os.remove(f)
if os.path.exists(WORKPATH + '/' + self.fixture_tmp):
os.remove(WORKPATH + '/' + self.fixture_tmp)
if __name__ == '__main__':
unittest.main()
|