class RandomUniformDistributionDateProviderTest(unittest.TestCase): """Test class for RandomUniformDistributionDateProvider. """ def setUp(self): self.provider = RandomUniformDistributionDateProvider() def tearDown(self): pass def testGetValue(self): """Tests RandomUniformDistributionDateProvider.getValue() """ min_year = '2000' min_month = '5' min_day = '10' max_year = '2012' max_month = '12' max_day = '24' self.provider.param_values = { 'min_year': min_year, 'min_month': min_month, 'min_day': min_day, 'max_year': max_year, 'max_month': max_month, 'max_day': max_day } value = self.provider.getValue() min_date = datetime.date(int(min_year), int(min_month), int(min_day)) max_date = datetime.date(int(max_year), int(max_month), int(max_day)) self.assertTrue(min_date <= value <= max_date) def testGetValueWithInvalidParameters(self): """Tests RandomUniformDistributionDateProvider.getValue() with invalid parameters. """ self.provider.param_values = {'min_year': 'asdf'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_year': '-1'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_year': '2000', 'max_year': '1990'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_month': '13'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_day': '32'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_month': '2', 'min_day': '31'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_month': '1', 'min_day': '31'} self.provider.getValue()
class RandomUniformDistributionDateProviderTest(unittest.TestCase): """Test class for RandomUniformDistributionDateProvider. """ def setUp(self): self.provider = RandomUniformDistributionDateProvider() def tearDown(self): pass def testGetValue(self): """Tests RandomUniformDistributionDateProvider.getValue() """ min_year = '2000' min_month = '5' min_day = '10' max_year = '2012' max_month = '12' max_day = '24' self.provider.param_values = {'min_year': min_year, 'min_month': min_month, 'min_day': min_day, 'max_year': max_year, 'max_month': max_month, 'max_day': max_day} value = self.provider.getValue() min_date = datetime.date(int(min_year), int(min_month), int(min_day)) max_date = datetime.date(int(max_year), int(max_month), int(max_day)) self.assertTrue(min_date <= value <= max_date) def testGetValueWithInvalidParameters(self): """Tests RandomUniformDistributionDateProvider.getValue() with invalid parameters. """ self.provider.param_values = {'min_year': 'asdf'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_year': '-1'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_year': '2000', 'max_year': '1990'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_month': '13'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_day': '32'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_month': '2', 'min_day': '31'} self.assertRaises(ParameterValueError, self.provider.getValue) self.provider.param_values = {'min_month': '1', 'min_day': '31'} self.provider.getValue()
def setUp(self): self.provider = RandomUniformDistributionDateProvider()