from factory import SubFactory

from pycroft.model.config import Config
from .base import BaseFactory
from .finance import AccountFactory, BankAccountFactory
from .property import PropertyGroupFactory, MemberPropertyGroupFactory


class ConfigFactory(BaseFactory):
    """This is a dummy Config factory, Referencing PropertyGroups with
    no a-priori property relationships and arbitrary Accounts.
    """
    class Meta:
        model = Config

    id = 1

    # `PropertyGroup`s
    member_group = SubFactory(MemberPropertyGroupFactory)
    network_access_group = SubFactory(PropertyGroupFactory)
    violation_group = SubFactory(PropertyGroupFactory)
    cache_group = SubFactory(PropertyGroupFactory)
    traffic_limit_exceeded_group = SubFactory(PropertyGroupFactory)
    external_group = SubFactory(PropertyGroupFactory)
    payment_in_default_group = SubFactory(PropertyGroupFactory)
    blocked_group = SubFactory(PropertyGroupFactory)
    caretaker_group = SubFactory(PropertyGroupFactory)
    treasurer_group = SubFactory(PropertyGroupFactory)

    # `Account`s
    membership_fee_account = SubFactory(AccountFactory)
    membership_fee_bank_account = SubFactory(BankAccountFactory)

from factory import SubFactory

from pycroft.model.config import Config
from .base import BaseFactory
from .finance import AccountFactory, BankAccountFactory
from .property import PropertyGroupFactory, MemberPropertyGroupFactory


class ConfigFactory(BaseFactory):
    """This is a dummy Config factory, Referencing PropertyGroups with
    no a-priori property relationships and arbitrary Accounts.
    """
    class Meta:
        model = Config

    id = 1

    # `PropertyGroup`s
    member_group = SubFactory(MemberPropertyGroupFactory)
    network_access_group = SubFactory(PropertyGroupFactory)
    violation_group = SubFactory(PropertyGroupFactory)
    cache_group = SubFactory(PropertyGroupFactory)
    traffic_limit_exceeded_group = SubFactory(PropertyGroupFactory)
    external_group = SubFactory(PropertyGroupFactory)
    payment_in_default_group = SubFactory(PropertyGroupFactory,
                                          granted=frozenset(("payment_in_default",)),
                                          denied=frozenset(("network_access", "userwww", "userdb")))
    blocked_group = SubFactory(PropertyGroupFactory)
    caretaker_group = SubFactory(PropertyGroupFactory)
    treasurer_group = SubFactory(PropertyGroupFactory)

    # `Account`s
    membership_fee_account = SubFactory(AccountFactory)
    membership_fee_bank_account = SubFactory(BankAccountFactory)

Add correct properties for payment_in_default test group
Add correct properties for payment_in_default test group


  from factory import SubFactory
  
  from pycroft.model.config import Config
  from .base import BaseFactory
  from .finance import AccountFactory, BankAccountFactory
  from .property import PropertyGroupFactory, MemberPropertyGroupFactory
  
  
  class ConfigFactory(BaseFactory):
      """This is a dummy Config factory, Referencing PropertyGroups with
      no a-priori property relationships and arbitrary Accounts.
      """
      class Meta:
          model = Config
  
      id = 1
  
      # `PropertyGroup`s
      member_group = SubFactory(MemberPropertyGroupFactory)
      network_access_group = SubFactory(PropertyGroupFactory)
      violation_group = SubFactory(PropertyGroupFactory)
      cache_group = SubFactory(PropertyGroupFactory)
      traffic_limit_exceeded_group = SubFactory(PropertyGroupFactory)
      external_group = SubFactory(PropertyGroupFactory)
-     payment_in_default_group = SubFactory(PropertyGroupFactory)
+     payment_in_default_group = SubFactory(PropertyGroupFactory,
+                                           granted=frozenset(("payment_in_default",)),
+                                           denied=frozenset(("network_access", "userwww", "userdb")))
      blocked_group = SubFactory(PropertyGroupFactory)
      caretaker_group = SubFactory(PropertyGroupFactory)
      treasurer_group = SubFactory(PropertyGroupFactory)
  
      # `Account`s
      membership_fee_account = SubFactory(AccountFactory)
      membership_fee_bank_account = SubFactory(BankAccountFactory)
  
Add correct properties for payment_in_default test group
## Code Before:
from factory import SubFactory

from pycroft.model.config import Config
from .base import BaseFactory
from .finance import AccountFactory, BankAccountFactory
from .property import PropertyGroupFactory, MemberPropertyGroupFactory


class ConfigFactory(BaseFactory):
    """This is a dummy Config factory, Referencing PropertyGroups with
    no a-priori property relationships and arbitrary Accounts.
    """
    class Meta:
        model = Config

    id = 1

    # `PropertyGroup`s
    member_group = SubFactory(MemberPropertyGroupFactory)
    network_access_group = SubFactory(PropertyGroupFactory)
    violation_group = SubFactory(PropertyGroupFactory)
    cache_group = SubFactory(PropertyGroupFactory)
    traffic_limit_exceeded_group = SubFactory(PropertyGroupFactory)
    external_group = SubFactory(PropertyGroupFactory)
    payment_in_default_group = SubFactory(PropertyGroupFactory)
    blocked_group = SubFactory(PropertyGroupFactory)
    caretaker_group = SubFactory(PropertyGroupFactory)
    treasurer_group = SubFactory(PropertyGroupFactory)

    # `Account`s
    membership_fee_account = SubFactory(AccountFactory)
    membership_fee_bank_account = SubFactory(BankAccountFactory)

## Instruction:
Add correct properties for payment_in_default test group
## Code After:
from factory import SubFactory

from pycroft.model.config import Config
from .base import BaseFactory
from .finance import AccountFactory, BankAccountFactory
from .property import PropertyGroupFactory, MemberPropertyGroupFactory


class ConfigFactory(BaseFactory):
    """This is a dummy Config factory, Referencing PropertyGroups with
    no a-priori property relationships and arbitrary Accounts.
    """
    class Meta:
        model = Config

    id = 1

    # `PropertyGroup`s
    member_group = SubFactory(MemberPropertyGroupFactory)
    network_access_group = SubFactory(PropertyGroupFactory)
    violation_group = SubFactory(PropertyGroupFactory)
    cache_group = SubFactory(PropertyGroupFactory)
    traffic_limit_exceeded_group = SubFactory(PropertyGroupFactory)
    external_group = SubFactory(PropertyGroupFactory)
    payment_in_default_group = SubFactory(PropertyGroupFactory,
                                          granted=frozenset(("payment_in_default",)),
                                          denied=frozenset(("network_access", "userwww", "userdb")))
    blocked_group = SubFactory(PropertyGroupFactory)
    caretaker_group = SubFactory(PropertyGroupFactory)
    treasurer_group = SubFactory(PropertyGroupFactory)

    # `Account`s
    membership_fee_account = SubFactory(AccountFactory)
    membership_fee_bank_account = SubFactory(BankAccountFactory)
