Example #1
0
class RandomReferenceProviderTest(unittest.TestCase):
    """Test class for UniformDistributionIntegerProvider.
  """
    def setUp(self):
        self.provider = RandomReferenceProvider()

    def tearDown(self):
        pass

    def testGetValue(self):
        """Tests getValue()
    """
        data = [
            {
                'link_id': 'asdf'
            },
            {
                'link_id': 'asdf2'
            },
            {
                'link_id': 'asdf3'
            },
        ]
        for properties in data:
            # pylint: disable=W0142
            inst = Timeline(**properties)
            inst.put()
            # pylint: enable=W0142

        model_name = 'soc.models.timeline.Timeline'
        seeder_models_logic.registerModel(model_name, Timeline)
        self.provider.param_values = {'model_name': model_name}

        value = self.provider.getValue()
        self.assertTrue(value.link_id in ['asdf', 'asdf2', 'asdf3'])

    def testGetValueWithInvalidParameters(self):
        """Tests getValue() with invalid and missing model name.
    """
        self.provider.param_values = {}
        self.assertRaises(MissingParameterError, self.provider.getValue)

        self.provider.param_values = {'model_name': 'asdf'}
        self.assertRaises(ParameterValueError, self.provider.getValue)

    def testGetValueWithNoModels(self):
        model_name = 'soc.models.timeline.Timeline'
        seeder_models_logic.registerModel(model_name, Timeline)
        self.provider.param_values = {'model_name': model_name}

        value = self.provider.getValue()
        self.assertEquals(value, None)
Example #2
0
class RandomReferenceProviderTest(unittest.TestCase):
  """Test class for UniformDistributionIntegerProvider.
  """

  def setUp(self):
    self.provider = RandomReferenceProvider()

  def tearDown(self):
    pass

  def testGetValue(self):
    """Tests getValue()
    """
    data = [
      {'link_id': 'asdf'},
      {'link_id': 'asdf2'},
      {'link_id': 'asdf3'},
      ]
    for properties in data:
      # pylint: disable=W0142
      inst = Timeline(**properties)
      inst.put()
      # pylint: enable=W0142

    model_name = 'soc.models.timeline.Timeline'
    seeder_models_logic.registerModel(model_name, Timeline)
    self.provider.param_values = {'model_name': model_name}

    value = self.provider.getValue()
    self.assertTrue(value.link_id in ['asdf', 'asdf2', 'asdf3'])

  def testGetValueWithInvalidParameters(self):
    """Tests getValue() with invalid and missing model name.
    """
    self.provider.param_values = {}
    self.assertRaises(MissingParameterError, self.provider.getValue)

    self.provider.param_values = {'model_name': 'asdf'}
    self.assertRaises(ParameterValueError, self.provider.getValue)

  def testGetValueWithNoModels(self):
    model_name = 'soc.models.timeline.Timeline'
    seeder_models_logic.registerModel(model_name, Timeline)
    self.provider.param_values = {'model_name': model_name}

    value = self.provider.getValue()
    self.assertEquals(value, None)
Example #3
0
 def setUp(self):
   self.provider = RandomReferenceProvider()
Example #4
0
 def setUp(self):
     self.provider = RandomReferenceProvider()