Heat the oil in a saucepan, add the onion and fry for 5 minutes until softened. Add the garlic, tomatoes and sugar, and season with salt and pepper. Cover and simmer gently for 15 minutes, stirring from time to time until the sauce has thickened. Leave to cool slightly.
Cut the pastry into 6, then roll out each piece on a lightly floured surface and trim to a 15 cm (6 inch) circle using a saucer as a guide. Press each pastry circle into the base of a lightly oiled metal Yorkshire pudding tin or tart tin, 10 cm (4 inches) in diameter, 2.5 cm (1 inch) deep, and press the pastry at intervals to the sides of the tin to give a wavy edge.
Reserve half the smaller basil leaves for garnish, tear the larger leaves into pieces and stir into the sauce. Divide the sauce between the pies and spread into an even layer. Cut the mozzarella into 6 slices and add a slice to each pie. Sprinkle the mozzarella with a little salt and pepper, and add an olive to each, if using.
Bake in a preheated oven, 200°C (400°F), Gas Mark 6, for 20 minutes until the pastry is crisp and golden. Leave to cool for 5 minutes, then turn out. Drizzle with a little olive oil, if liked, sprinkle with remaining basil leaves and serve warm with salad.