# Path: oscar_mws/test/factories.py
# class AmazonMarketplaceFactory(factory.DjangoModelFactory):
#     FACTORY_FOR = get_model('oscar_mws', 'AmazonMarketplace')
# 
#     name = "Dummy Marketplace"
#     region = MWS_MARKETPLACE_US
#     marketplace_id = factory.Sequence(lambda n: 'MWS_MKT_{}'.format(n))
#     merchant = factory.SubFactory(MerchantAccountFactory)


from django.db.models import get_model
from django.core.urlresolvers import reverse
from oscar.test import factories
from oscar.test.testcases import WebTestCase
from oscar_mws.test.factories import AmazonMarketplaceFactory



AmazonProfile = get_model('oscar_mws', 'AmazonProfile')


class TestAmazonProfile(WebTestCase):
    is_staff = True

    def setUp(self):
        super(TestAmazonProfile, self).setUp()
        self.product = factories.create_product()
        self.marketplace = AmazonMarketplaceFactory()

    def test_can_create_amazon_profile(self):
        create_page = self.get(
            reverse(
                'mws-dashboard:profile-create',
                kwargs={'pk': self.product.pk}
            )
        )

        profile_form = create_page.form
        profile_form['sku'] = 'fake12345'
        profile_form['marketplaces'] = [self.marketplace.id]

# Path: oscar_mws/test/factories.py
# class AmazonMarketplaceFactory(factory.DjangoModelFactory):
#     FACTORY_FOR = get_model('oscar_mws', 'AmazonMarketplace')
# 
#     name = "Dummy Marketplace"
#     region = MWS_MARKETPLACE_US
#     marketplace_id = factory.Sequence(lambda n: 'MWS_MKT_{}'.format(n))
#     merchant = factory.SubFactory(MerchantAccountFactory)


# Path: tests/functional/test_profile_dashboard.py
from django.db.models import get_model
from django.core.urlresolvers import reverse
from oscar.test import factories
from oscar.test.testcases import WebTestCase
from oscar_mws.test.factories import AmazonMarketplaceFactory




AmazonProfile = get_model('oscar_mws', 'AmazonProfile')


class TestAmazonProfile(WebTestCase):
    is_staff = True

    def setUp(self):
        super(TestAmazonProfile, self).setUp()
        self.product = factories.create_product()
        self.marketplace = AmazonMarketplaceFactory()

    def test_can_create_amazon_profile(self):
        create_page = self.get(
            reverse(
                'mws-dashboard:profile-create',
                kwargs={'pk': self.product.pk}
            )
        )

        profile_form = create_page.form
        profile_form['sku'] = 'fake12345'
        profile_form['marketplaces'] = [self.marketplace.id]

        page = profile_form.submit()