def test_set_type(self):
        instance = MagicMock(MODES=BillingConfiguration.MODES)

        BillingConfiguration.set_type(instance,
                                      BillingConfiguration.FIXED_MODE, True)
        self.assertEqual(instance.mode, BillingConfiguration.FIXED_MODE)
        self.assertEqual(instance.is_discount, True)
    def test_init_custom_fields(self, mocked_set_type):
        instance = MagicMock(_allow_empty=False, set_type=mocked_set_type)

        BillingConfiguration.init_custom_fields(instance, "foo", "foo")

        self.assertIsInstance(mocked_set_type, MagicMock)
        mocked_set_type.assert_called_once_with("foo", "foo")
    def test_get_validation_fields_allow_empty(self):
        instance = BillingConfiguration(allow_empty=True)
        self.assertIsInstance(instance, BillingConfiguration)

        self.assertEqual({"mode"}, instance.get_validation_fields())
    def test_get_all_fields(self):
        instance = MagicMock(get_validation_fields=MagicMock(
            return_value=set()))

        self.assertEqual(set(), BillingConfiguration.get_all_fields(instance))
 def test_get_percent_required_fields(self):
     self.assertIsSubSet({"percentage"},
                         BillingConfiguration.get_percent_required_fields())
 def test_get_fixed_required_fields(self):
     self.assertIsSubSet({"amount"},
                         BillingConfiguration.get_fixed_required_fields())
 def test_get_discount_required_fields(self):
     self.assertIsSubSet(
         {"limit_date"},
         BillingConfiguration.get_discount_required_fields())
 def test_get_fee_required_fields(self):
     self.assertIsSubSet({"start_date"},
                         BillingConfiguration.get_fee_required_fields())
 def test_required_fields(self):
     self.assertEqual({"mode"}, BillingConfiguration.get_required_fields())
 def test_validate_mode():
     instance = MagicMock(_allow_empty=False, mode="foo")
     BillingConfiguration.validate_mode(instance,
                                        BillingConfiguration.FIXED_MODE)