from django.core.urlresolvers import reverse
from rest_framework.status import HTTP_200_OK

from timed.projects.factories import (BillingTypeFactory, CustomerFactory,
                                      ProjectFactory)
from timed.subscription.factories import PackageFactory


def test_subscription_package_list(auth_client):
    PackageFactory.create()

    url = reverse('subscription-package-list')

    res = auth_client.get(url)
    assert res.status_code == HTTP_200_OK

    json = res.json()
    assert len(json['data']) == 1


def test_subscription_package_filter_customer(auth_client):
    customer = CustomerFactory.create()
    billing_type = BillingTypeFactory.create()
    package = PackageFactory.create(billing_type=billing_type)
    ProjectFactory.create(billing_type=billing_type, customer=customer)

    my_project = ProjectFactory.create(
        billing_type=billing_type,
        customer=customer
    )

    url = reverse('subscription-package-list')

    res = auth_client.get(url, data={'customer': my_project.customer.id})
    assert res.status_code == HTTP_200_OK

    json = res.json()
    assert len(json['data']) == 1
    assert json['data'][0]['id'] == str(package.id)

@@ -769,95 +769,26 @@
 eate
-(billing_type=billing_type, customer=customer)%0A%0A    my_project = ProjectFactory.create(
+_batch(%0A        2,
 %0A   
@@ -818,24 +818,16 @@
 ng_type,
-%0A       
  custome
@@ -945,19 +945,8 @@
 r': 
-my_project.
 cust

remove unnecessary assignment from package test