Are you assuming that by testing a nuclear explosive device Iran will automatically have nuclear weapons forthright? That's not the case.
First, Iran needs to somehow enrich uranium to 90%. It seems to difficult to do so immediately.
Second, let's assume Iran does enrich U-235 to 90%, it will then have to develop its test explosive device.
Third, let's assume test takes place, its success will depend on if the yield is supercritical and enough for weapons development.
Fourth, let's assume test is successful and the yield is good enough for weapons development, it will only validate that Iran now has the full capacity but not the capability, i.e. the weapon itself.
Fifth, to translate the capacity into capability, Iran will need to analyze the hot test data and design nuclear warhead accordingly. The warhead should be able to be incorporated on Iran's ballistic missile (the IRIAF is a non-factor, so gravity bombs are the door. Otherwise it might be "relatively" quick to develop a rudimentary nuke bomb for the air force as stand-in measure).
- Iran's warhead choice will be between gun-barrel or implosion-device. In the case of former, the trigger mechanism needs to be timed - its a science of nanoseconds with critical mass coming together and neutrons releasing on time, not before or after, otherwise the bomb would either explode untimely (perhaps somewhere over Iran itself) or fizzle out. These calculations take time and multiple cold test in congruence with the hot test data. Implosion-type device is usually not used for uranium based atomic bomb and is more intricate than gun-barrel. It is used for plutonium based devices and since Iran has no known plutonium reprocessing facility we'll have to rule this one out.
- Iran would also need to develop new ballistic casing suitable for housing nuclear package. Casing should be able ensure that isotopes from the U-235 do not escape outside and the critical mass remains intact for a long-long duration.
In short, transforming a succesful nuclear test into a weapons capability is a complex process that takes time - which might be enough time to for the US and Israel to do a bombing run again across Iran and perhaps enforce regime change. Whether the regime survives or not is besides the point (they'll leave Reza Pahalvi hanging on the rope for all they care). But they would have done away with all things nuclear by then. India and Pakistan both tested nuclear devices in 1998, and save for the handful of rudimentary gravity bombs with their respective air forces, niether actually had deliverable weapons until 2001-2002. Taking that as a bench mark, I would say it might take Iran 2 to 3 years to achieve ballistic missile based credible nuclear deterrence.