예제 #1
0
 def test_variantpref_pref_value_returns_str_when_type_is_str(self):
     vp = VariantPreferencesFactory.create(
         pref_type=Experiment.PREF_TYPE_STR,
         pref_value="it's another string")
     value = PrefValueField(type_field="pref_type",
                            value_field="pref_value").to_representation(vp)
     self.assertEqual(value, "it's another string")
예제 #2
0
 def test_variant_pref_value_str_returns_bool_when_type_is_str(self):
     experiment = ExperimentFactory.create(
         pref_type=Experiment.PREF_TYPE_STR)
     variant = ExperimentVariantFactory.create(experiment=experiment,
                                               value="it's a string")
     value = PrefValueField(type_field="experiment__pref_type",
                            value_field="value").to_representation(variant)
     self.assertEqual(value, "it's a string")
예제 #3
0
 def test_variant_pref_value_returns_bool_when_type_is_bool(self):
     experiment = ExperimentFactory.create(
         pref_type=Experiment.PREF_TYPE_BOOL)
     variant = ExperimentVariantFactory.create(experiment=experiment,
                                               value="false")
     value = PrefValueField(type_field="experiment__pref_type",
                            value_field="value").to_representation(variant)
     self.assertEqual(value, False)
예제 #4
0
 def test_variantpref_pref_value_returns_int_when_type_is_int(self):
     vp = VariantPreferencesFactory.create(
         pref_type=Experiment.PREF_TYPE_INT, pref_value="22")
     value = PrefValueField(type_field="pref_type",
                            value_field="pref_value").to_representation(vp)
     self.assertEqual(value, 22)