def test_get_or_create_multiple_with_null(self): # Check if get_or_creating is working properly when using references # with null values. item_a = ProductionProducedItem.get_or_create( self.store, serial_number=456, product=None) self.assertEquals(item_a.serial_number, 456) self.assertEquals(item_a.product, None) item_b = ProductionProducedItem.get_or_create( self.store, serial_number=456, product=None) self.assertEquals(item_a, item_b)
def test_get_or_create_multiple(self): # This test is for get_or_create call with more than one property product = self.create_product() # Make sure there is no item yet. item = self.store.find(ProductionProducedItem, serial_number=123, product=product).one() self.assertEquals(item, None) # First call to get_or_create should create the object. item_a = ProductionProducedItem.get_or_create( self.store, serial_number=123, product=product) # And set the properties given self.assertEquals(item_a.serial_number, 123) self.assertEquals(item_a.product, product) # The second call to get_or_create should return the same object item_b = ProductionProducedItem.get_or_create( self.store, serial_number=123, product=product) self.assertEquals(item_a, item_b)