Ejemplo n.º 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")
Ejemplo n.º 2
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)
Ejemplo n.º 3
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")
Ejemplo n.º 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)