Пример #1
0
    def test_can_create_feed_for_base_attributes(self):
        product = create_product()
        profile = factories.AmazonProfileFactory(
            product=product, release_date=UTC_NOW)

        mapper = ProductMapper(product=product)
        xml = etree.tostring(mapper.get_product_xml())
        self.assertIn(
            '<SKU>{0}</SKU>'.format(profile.sku), xml)
        self.assertIn(
            '<ReleaseDate>{0}</ReleaseDate>'.format(UTC_NOW.isoformat()), xml)
        self.assertIn('<Title>{0}</Title>'.format(product.title), xml)
Пример #2
0
class TestBaseProductMapper(TestCase):

    def setUp(self):
        super(TestBaseProductMapper, self).setUp()
        self.mapper = ProductMapper(product=mock.MagicMock())

    def test_gets_value_from_object_attribute(self):
        class Mock(object):
            pass

        obj = Mock()
        obj.test_attribute = 'amazing value'

        self.assertEquals(
            self.mapper._get_value_from(obj, 'test_attribute'),
            obj.test_attribute
        )

    def test_gets_value_from_object_getter(self):
        obj = mock.Mock()
        obj.get_test_attribute = mock.Mock(return_value='amazing value')

        self.assertEquals(self.mapper._get_value_from(obj, 'test_attribute'),
                          obj.get_test_attribute())

    def test_can_create_feed_for_base_attributes(self):
        product = create_product()
        profile = factories.AmazonProfileFactory(
            product=product, release_date=UTC_NOW)

        mapper = ProductMapper(product=product)
        xml = etree.tostring(mapper.get_product_xml())
        self.assertIn(
            '<SKU>{0}</SKU>'.format(profile.sku), xml)
        self.assertIn(
            '<ReleaseDate>{0}</ReleaseDate>'.format(UTC_NOW.isoformat()), xml)
        self.assertIn('<Title>{0}</Title>'.format(product.title), xml)
Пример #3
0
 def setUp(self):
     super(TestBaseProductMapper, self).setUp()
     self.mapper = ProductMapper(product=mock.MagicMock())