If there is no free space in the Egg inventory, it's impossible to obtain an Alola Egg. Is this checked when the Gift is received whether you open it or not (much like the eggs), or it is checked at the moment you try to open it?
It is checked the moment you try to open the gift, not when you receive the gift. If you have free space when you open the gift, you have a chance to receive an Alolan egg. Note the word chance: it is not guaranteed you'd get an egg even if you open a gift with free space.
As per this question and answer, there are cases of Pokemon receiving Pokemon from eggs that were available when the eggs were open, but not when the gifts were received.