def all(self): product1 = products.ProductsDetails(product_id='11', product_name='Test1', product_type='Test Type') product2 = products.ProductsDetails(product_id='22', product_name='Test2', product_type='Test Type') return [product1, product2]
def all(self): #pylint: disable=no-self-use """Overriding all() method of objects.""" product1 = products.ProductsDetails(product_id='11', product_name='Test1', product_type='Cisco 5SA') product2 = products.ProductsDetails(product_id='22', product_name='Test2', product_type='Cisco 5SA') return [product1, product2]
def test_cached_delete(self): # pylint: disable=no-self-use """Test for cached_delete function.""" product_details_obj = products.ProductsDetails() product_details_obj.delete = MagicMock() products.ProductsDetails.get.return_value = product_details_obj products.ProductsDetails.cached_delete(product_id='1234') db_cache_mixin.REDIS_CLIENT.delete.assert_calls_once_with( product_id='1234') products.ProductsDetails.get.assert_calls_once_with(product_id='1234') product_details_obj.delete.assert_calls_once()
def test_get(self): """Test for cached_get function.""" products.ProductsDetails.product_id = self.product_id products.ProductsDetails.product_name = self.product_name products.ProductsDetails.product_type = self.product_type product_details_obj = products.ProductsDetails() products.ProductsDetails.cached_get.return_value = product_details_obj result = self.product.get(product_id=self.product_id) self.assertTrue(result['success']) self.assertEquals(result['data'], self.value) products.ProductsDetails.cached_get.assert_called_once_with( product_id=self.product_id)
def test_properties(self): """Test for properties available in ProductDetails model.""" product_details = products.ProductsDetails() available_keys = product_details.keys() expected_keys = ['product_id', 'product_name', 'product_type'] self.assertEquals(expected_keys, available_keys)