Typically, there is a switch underneath the gallery that is depressed when the galley is in the upright position. The switch in this photograph is just by the bunk bed on the left. In some PUPs this switch will be turned on when the bunk end is pulled out.
This is a closer look at the switch. In some cases the gallery may not push the switch down far enough to turn on the circuit. I once had to add a small piece of foam to keep it depressed. You can test if the switch is defective by removing it and either use a multimeter or place a small piece of wire between the terminals to see if the circuits closes and the lights come on.
Another place to look is the connector that runs between the box and the roof. Sometimes in closing or opening the PUP this connect may have come lose.