def test_bad_block(self): r = DateRange() state, data = r.processObject( { 'test': u'data', 'ver': 'var', 'data': '2017-11-24' }, [[]]) self.assertFalse(state) self.assertEqual(len(data), 0)
def test_bad_source(self): r = DateRange() state, data = r.processObject([], [{ 'field': 'data', 'min': '2017-11-24', 'format': '%Y-%m-%d', 'variable': True, 'variable_name': 'data' }]) self.assertFalse(state) self.assertEqual(len(data), 0)
def test_valid_no_variables(self): r = DateRange() state, data = r.processObject( { 'test': u'data', 'ver': 'var', 'data': '2017-11-24' }, [{ 'field': 'data', 'min': '2017-11-24', 'format': '%Y-%m-%d' }]) self.assertTrue(state) self.assertEqual(len(data), 0)
def test_invalid_config(self): r = DateRange() state, data = r.processObject( { 'test': u'data', 'ver': 'var', 'data': '2017-11-24' }, [{ 'field': 'data', 'min': '2017-11-24' # no format }]) self.assertFalse(state) self.assertEqual(len(data), 0)
def test_valid(self): r = DateRange() state, data = r.processObject( { 'test': u'data', 'ver': 'var', 'data': '2017-11-24' }, [{ 'field': 'data', 'min': '2017-11-24', 'format': '%Y-%m-%d', 'variable': True, 'variable_name': 'data' }]) self.assertTrue(state) self.assertEqual(data.get('data'), '2017-11-24')
def test_field_false(self): r = DateRange() state, data = r.processObject( { 'test': u'data', 'ver': 'var', 'data': False }, [{ 'field': 'data', 'min': '2017-11-24', 'format': '%Y-%m-%d', 'variable': True, 'variable_name': 'data' }]) self.assertFalse(state) self.assertEqual(len(data), 0)
def test_emptyList(self): r = DateRange() state, data = r.processObject({}, []) self.assertFalse(state) self.assertFalse(data)