def test_unemployment_a_periods_switching_to_e(self): """unemployment_a_periods when job seeker starts a training.""" job_seeker = fhs.JobSeeker({ 'de': [ { 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 12, 22), 'CATREGR': '1', }, { 'DATINS': datetime.date(2015, 12, 22), 'DATANN': datetime.date(2015, 12, 31), 'CATREGR': '5', }, ], 'e0': [], }) periods = job_seeker.unemployment_a_periods() self.assertEqual( fhs.DateIntervals([( datetime.date(2015, 5, 1), datetime.date(2015, 12, 22), {'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 12, 22), 'CATREGR': '1'})]), periods)
def test_unemployment_a_periods_useless_change(self): """unemployment_a_periods whith a change from CATREGR 1 to 2.""" job_seeker = fhs.JobSeeker({ 'de': [ { 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 12, 22), 'CATREGR': '1', 'MOTINS': 'aaa', 'MOTANN': 'bbb', }, { 'DATINS': datetime.date(2015, 12, 22), 'DATANN': datetime.date(2015, 12, 31), 'CATREGR': '2', 'MOTINS': 'ccc', 'MOTANN': 'ddd', }, ], 'e0': [], }) periods = job_seeker.unemployment_a_periods() self.assertEqual( fhs.DateIntervals([( datetime.date(2015, 5, 1), datetime.date(2015, 12, 31), {'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 12, 31), 'CATREGR': '2', 'MOTINS': 'aaa', 'MOTANN': 'ddd'})]), periods)
def test_unemployment_a_periods_switching_to_b(self): """unemployment_a_periods when job seeker starts partial work.""" job_seeker = fhs.JobSeeker({ 'de': [{ 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 12, 22), 'CATREGR': '1', }], 'e0': [{ 'MOIS': '201510' }, { 'MOIS': '201511' }, { 'MOIS': '201512' }], }) periods = job_seeker.unemployment_a_periods() self.assertEqual( fhs.DateIntervals([ (datetime.date(2015, 5, 1), datetime.date(2015, 10, 1), { 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 10, 1), 'CATREGR': '1', 'MOTANN': fhs.CancellationReason.STARTING_PART_TIME_WORK }) ]), periods)
def test_unemployment_a_periods_mistakenly_kicked_out(self): """unemployment_a_periods with a mistaken kick-out. Frequently some job seeker forget the required monthly updated of their data, or do not show up at a mandatory meeting with their counselor. When that happens Pôle Emploi kicks them out of their register (and stop the allowance). Usually the job seeker would then re-register very quickly to get their allowance back. We identify periods where a job seeker left the unemployment system for a short period, and treat such gaps as if they had never left. """ job_seeker = fhs.JobSeeker({ 'de': [ { 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 7, 31), 'CATREGR': '1', 'MOTINS': 'aaa', 'MOTANN': 'bbb', }, { 'DATINS': datetime.date(2015, 8, 12), 'DATANN': datetime.date(2015, 10, 31), 'CATREGR': '1', 'MOTINS': 'ccc', 'MOTANN': 'ddd', }, { 'DATINS': datetime.date(2015, 11, 13), 'DATANN': None, 'CATREGR': '1', 'MOTINS': 'eee', 'MOTANN': 'fff', }, ], 'e0': [], }) # The first two periods should be merged, but not the last one. periods = job_seeker.unemployment_a_periods(cover_holes_up_to=12) self.assertEqual( fhs.DateIntervals([ (datetime.date(2015, 5, 1), datetime.date(2015, 10, 31), {'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 10, 31), 'CATREGR': '1', 'MOTINS': 'aaa', 'MOTANN': 'ddd'}), (datetime.date(2015, 11, 13), None, {'DATINS': datetime.date(2015, 11, 13), 'DATANN': None, 'CATREGR': '1', 'MOTINS': 'eee', 'MOTANN': 'fff'})]), periods)
def test_state_at_date(self): """Basic usages of state_at_date.""" job_seeker = fhs.JobSeeker({ 'de': [ { 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 5, 22), 'CATREGR': '1', 'ROME': 'H1234', }, { 'DATINS': datetime.date(2015, 6, 1), 'DATANN': datetime.date(2015, 6, 22), 'CATREGR': '1', 'ROME': 'A1001', }, ], }) first_state = { 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 5, 22), 'CATREGR': '1', 'ROME': 'H1234', } tests = [ StateAtDateTestCase( name="In the middle", date=datetime.date(2015, 5, 10), expect=first_state), StateAtDateTestCase( name="Before unemployment", date=datetime.date(2014, 5, 10), expect=None), StateAtDateTestCase( name="After unemployment", date=datetime.date(2016, 5, 10), expect=None), StateAtDateTestCase( name="Between 2 unemployment periods", date=datetime.date(2015, 5, 30), expect=None), StateAtDateTestCase( name="First day of unemployment", date=datetime.date(2015, 5, 1), expect=first_state), StateAtDateTestCase( name="First day of employment", date=datetime.date(2015, 5, 22), expect=None), ] for test in tests: state = job_seeker.state_at_date(test.date) self.assertEqual(test.expect, state, msg=test.name)
def test_unemployment_a_periods(self): """Basic usage of unemployment_a_periods.""" job_seeker = fhs.JobSeeker({ 'de': [{ 'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 5, 22), 'CATREGR': '1', }], 'e0': [], }) periods = job_seeker.unemployment_a_periods() self.assertEqual( fhs.DateIntervals([( datetime.date(2015, 5, 1), datetime.date(2015, 5, 22), {'DATINS': datetime.date(2015, 5, 1), 'DATANN': datetime.date(2015, 5, 22), 'CATREGR': '1'})]), periods)