-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_test.py
74 lines (62 loc) · 2.95 KB
/
upload_test.py
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
# encoding: utf-8
"""Unit tests for the upload module."""
from os import path
import unittest
import upload
_TESTDATA_DIR = path.join(path.dirname(__file__), 'testdata')
class DataPrepareTestCase(unittest.TestCase):
"""Unit tests for data preparation methods/"""
def test_csv_to_dicts(self):
dicts = upload.csv_to_dicts(
path.join(_TESTDATA_DIR, 'unix_referentiel_appellation.csv'),
path.join(_TESTDATA_DIR, 'unix_referentiel_code_rome.csv'),
path.join(_TESTDATA_DIR, 'passage_fap2009_romev3.txt'),
path.join(_TESTDATA_DIR, 'jobs_frequency.json'))
self.assertEqual(13, len(dicts))
for job in dicts:
keys = set(job.keys()) - set(['codeFap'])
self.assertEqual([
'codeOgr',
'codeRome',
'codeTypeSectionAppellation',
'frequency',
'libelleAppellationCourt',
'libelleAppellationCourtFeminin',
'libelleAppellationCourtMasculin',
'libelleAppellationLong',
'libelleAppellationLongFeminin',
'libelleAppellationLongMasculin',
'libelleRome',
'libelleTypeSectionAppellation',
'statut',
], sorted(keys))
first_job = dicts[0]
self.assertEqual(
u'Abatteur / Abatteuse de carrière',
first_job['libelleAppellationCourt'])
self.assertEqual(
u'Abatteuse de carrière',
first_job['libelleAppellationCourtFeminin'])
self.assertEqual(
u'Abatteur de carrière',
first_job['libelleAppellationCourtMasculin'])
self.assertEqual('10200', first_job['codeOgr'])
self.assertEqual('F1402', first_job['codeRome'])
self.assertNotIn('codeFap', first_job)
self.assertEqual('Extraction solide', first_job['libelleRome'])
self.assertEqual(42, first_job['frequency'])
self.assertEqual('Accessoiriste', dicts[3]['libelleAppellationCourt'])
self.assertEqual('U1Z80', dicts[3]['codeFap'])
self.assertEqual('L1503', dicts[3]['codeRome'])
self.assertEqual(0, dicts[3]['frequency'])
self.assertEqual(u'Égoutier / Égoutière', dicts[10]['libelleAppellationCourt'])
self.assertEqual(u'Égoutier / Égoutière', dicts[10]['libelleAppellationLong'])
self.assertEqual(u'Égoutier', dicts[10]['libelleAppellationCourtMasculin'])
self.assertEqual('E1205', dicts[12]['codeRome'])
self.assertEqual('Product designer', dicts[12]['libelleAppellationCourt'])
self.assertEqual('Product designer', dicts[12]['libelleAppellationCourtMasculin'])
self.assertEqual('Product designer', dicts[12]['libelleAppellationCourtFeminin'])
self.assertEqual('Product designer', dicts[12]['libelleAppellationLong'])
self.assertEqual('126549a', dicts[12]['codeOgr'])
if __name__ == '__main__':
unittest.main()