# Path: tests/base.py
# class APITestCase(APITestCase):
#     client_class = APIClient
# 
# Path: tests/patterns_app/models.py
# class CustomPatternModel(models.Model):
#     name = models.CharField(max_length=10)
# 
# class CustomTypedPatternModel(models.Model):
#     name = models.CharField(max_length=10)
# 
# class CustomType(models.Model):
#     name = models.CharField(max_length=10)
# 
#     def __str__(self):
#         return self.name
# 
# class Campaign(models.Model):
#     pass
# 
# class Attribute(models.Model):
#     name = models.CharField(max_length=10)
#     campaign = models.ForeignKey(Campaign, models.CASCADE)
#     is_active = models.BooleanField()
#     category = models.CharField(max_length=10, blank=True)
# 
# class Entity(models.Model):
#     campaign = models.ForeignKey(Campaign, models.CASCADE)
# 
#     class Meta:
#         verbose_name_plural = 'entities'
# 
# Path: tests/patterns_app/serializers.py
# class EntitySerializerBase(patterns.AttachedModelSerializer):
#     values = ValueSerializerBase(many=True)
# 
#     class Meta:
#         model = Entity
#         fields = '__all__'
# 
# class EntitySerializerCampaignID(EntitySerializerBase):
#     values = ValueSerializerCampaignID(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerIsActiveT(EntitySerializerBase):
#     values = ValueSerializerIsActiveT(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerIsActiveF(EntitySerializerBase):
#     values = ValueSerializerIsActiveF(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerActiveTCampaignID(EntitySerializerBase):
#     values = ValueSerializerIsActiveTCampaignID(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerCategoryDim(EntitySerializerBase):
#     values = ValueSerializerCategoryDim(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerCategoryEmpty(EntitySerializerBase):
#     values = ValueSerializerCategoryEmpty(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerCategoryCtxt(EntitySerializerBase):
#     values = ValueSerializerCategoryCtxt(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass


from wq.db import rest
from .base import APITestCase
from rest_framework import status
from django.contrib.auth.models import User
from tests.patterns_app.models import (
    CustomPatternModel, CustomTypedPatternModel, CustomType,
    Campaign, Attribute, Entity
    )
from tests.patterns_app.serializers import (
    EntitySerializerBase, EntitySerializerCampaignID,
    EntitySerializerIsActiveT, EntitySerializerIsActiveF,
    EntitySerializerActiveTCampaignID, EntitySerializerCategoryDim,
    EntitySerializerCategoryEmpty, EntitySerializerCategoryCtxt,
    )
        self.assertEqual(self.typeinstance.name, "Test 2'")
        self.assertEqual(self.typeinstance.attachments.count(), 1)
        self.assertEqual(
            self.typeinstance.attachments.first().type, self.type
        )

    def test_eavfilter_empty(self):
        rest.router.register_serializer(
            Entity,
            EntitySerializerBase)

        response = self.client.get('/entities/new.json')
        self.assertEqual(
            [self.att1.id, self.att2.id, self.att3.id, self.att4.id],
            [i['attribute_id'] for i in response.data['values']])

    def test_eavfilter_cid(self):
        rest.router.register_serializer(
            Entity,
            EntitySerializerCampaignID)

        response = self.client.get(
            '/entities/new.json?campaign_id={}'.format(self.campaign2.id))
        self.assertEqual(
            [self.att3.id, self.att4.id],
            [i['attribute_id'] for i in response.data['values']])

    def test_eavfilter_cid_miss(self):
        rest.router.register_serializer(
            Entity,

# Path: tests/base.py
# class APITestCase(APITestCase):
#     client_class = APIClient
# 
# Path: tests/patterns_app/models.py
# class CustomPatternModel(models.Model):
#     name = models.CharField(max_length=10)
# 
# class CustomTypedPatternModel(models.Model):
#     name = models.CharField(max_length=10)
# 
# class CustomType(models.Model):
#     name = models.CharField(max_length=10)
# 
#     def __str__(self):
#         return self.name
# 
# class Campaign(models.Model):
#     pass
# 
# class Attribute(models.Model):
#     name = models.CharField(max_length=10)
#     campaign = models.ForeignKey(Campaign, models.CASCADE)
#     is_active = models.BooleanField()
#     category = models.CharField(max_length=10, blank=True)
# 
# class Entity(models.Model):
#     campaign = models.ForeignKey(Campaign, models.CASCADE)
# 
#     class Meta:
#         verbose_name_plural = 'entities'
# 
# Path: tests/patterns_app/serializers.py
# class EntitySerializerBase(patterns.AttachedModelSerializer):
#     values = ValueSerializerBase(many=True)
# 
#     class Meta:
#         model = Entity
#         fields = '__all__'
# 
# class EntitySerializerCampaignID(EntitySerializerBase):
#     values = ValueSerializerCampaignID(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerIsActiveT(EntitySerializerBase):
#     values = ValueSerializerIsActiveT(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerIsActiveF(EntitySerializerBase):
#     values = ValueSerializerIsActiveF(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerActiveTCampaignID(EntitySerializerBase):
#     values = ValueSerializerIsActiveTCampaignID(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerCategoryDim(EntitySerializerBase):
#     values = ValueSerializerCategoryDim(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerCategoryEmpty(EntitySerializerBase):
#     values = ValueSerializerCategoryEmpty(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass
# 
# class EntitySerializerCategoryCtxt(EntitySerializerBase):
#     values = ValueSerializerCategoryCtxt(many=True)
# 
#     class Meta(EntitySerializerBase.Meta):
#         pass


# Path: tests/test_custompatterns.py
from wq.db import rest
from .base import APITestCase
from rest_framework import status
from django.contrib.auth.models import User
from tests.patterns_app.models import (
    CustomPatternModel, CustomTypedPatternModel, CustomType,
    Campaign, Attribute, Entity
    )
from tests.patterns_app.serializers import (
    EntitySerializerBase, EntitySerializerCampaignID,
    EntitySerializerIsActiveT, EntitySerializerIsActiveF,
    EntitySerializerActiveTCampaignID, EntitySerializerCategoryDim,
    EntitySerializerCategoryEmpty, EntitySerializerCategoryCtxt,
    )

        self.assertEqual(self.typeinstance.name, "Test 2'")
        self.assertEqual(self.typeinstance.attachments.count(), 1)
        self.assertEqual(
            self.typeinstance.attachments.first().type, self.type
        )

    def test_eavfilter_empty(self):
        rest.router.register_serializer(
            Entity,
            EntitySerializerBase)

        response = self.client.get('/entities/new.json')
        self.assertEqual(
            [self.att1.id, self.att2.id, self.att3.id, self.att4.id],
            [i['attribute_id'] for i in response.data['values']])

    def test_eavfilter_cid(self):
        rest.router.register_serializer(
            Entity,
            EntitySerializerCampaignID)

        response = self.client.get(
            '/entities/new.json?campaign_id={}'.format(self.campaign2.id))
        self.assertEqual(
            [self.att3.id, self.att4.id],
            [i['attribute_id'] for i in response.data['values']])

    def test_eavfilter_cid_miss(self):
        rest.router.register_serializer(
            Entity,

            EntitySerializerCampaignID)