def setUp(self): super(WithFakePaymentsConfig, self).setUp() sellers, products = payments_config.populate(fake_payments_config) for attr, val in (('products', products), ('sellers', sellers)): p = mock.patch.object(payments_config, attr, val) p.start() self.addCleanup(p.stop)
def setUp(self): super(ProductsTest, self).setUp() products = mock.patch('payments_config.products', name='products') self.product_mock = products.start() self.product_mock.get = populate(self.product_config)[1].get self.product_mock.patcher = products self.addCleanup(self.product_mock.patcher.stop)
def test_populate(self): sellers, products = populate(self.data) assert sellers['moz'].kind == 'products' assert products['moz-test'].amount == 3
def test_duplicated_product(self): self.data['moz']['products'].append(example_data['products'][0]) with self.assertRaisesRegexp(ValueError, 'Repeated product'): populate(self.data)