예제 #1
0
def recreate_db():
    """Recreate the database
    """
    db.drop_all()
    db.create_all()
    db.session.commit()
    print("Database has been dropped and recreated.")
예제 #2
0
파일: base.py 프로젝트: AlbertaSat/_ex2_
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.get(self.get_server_url())

        db.drop_all()
        db.create_all()
        db.session.commit()

        # seed the database for testing
        timestamp = datetime.fromtimestamp(1570749472)
        for i in range(20):
            housekeepingData = fakeHousekeepingAsDict(timestamp + timedelta(
                minutes=i * 15))
            housekeeping = Housekeeping(**housekeepingData)

            for i in range(1, 25):
                channel = fake_power_channel_as_dict(i)
                p = PowerChannels(**channel)
                housekeeping.channels.append(p)

            db.session.add(housekeeping)
        db.session.commit()

        commands = {
            'ping': (0, False),
            'get-hk': (0, False),
            'turn-on': (1, True),
            'turn-off': (1, True),
            'set-fs': (1, True),
            'upload-fs': (0, False)
        }

        for name, (num_args, is_danger) in commands.items():
            c = add_telecommand(command_name=name,
                                num_arguments=num_args,
                                is_dangerous=is_danger)

        command = Telecommands.query.filter_by(command_name='ping').first()
        flightschedule = add_flight_schedule(creation_date=timestamp,
                                             upload_date=timestamp,
                                             status=2,
                                             execution_time=timestamp)
        flightschedule_commands = add_command_to_flightschedule(
            timestamp=timestamp,
            flightschedule_id=flightschedule.id,
            command_id=command.id)

        add_user(username='******', password='******', is_admin=True)
        add_user(username='******', password='******', is_admin=False)
        add_user(username='******', password='******', is_admin=False)
        command = Telecommands.query.filter_by(command_name='turn-on').first()
        flightschedule_commands = add_command_to_flightschedule(
            timestamp=timestamp,
            flightschedule_id=flightschedule.id,
            command_id=command.id)

        flightschedulecommand_arg = add_arg_to_flightschedulecommand(
            index=0,
            argument='5',
            flightschedule_command_id=flightschedule_commands.id)

        message = add_message_to_communications(timestamp=timestamp,
                                                message='ping',
                                                sender='user',
                                                receiver='comm')

        now = datetime.utcnow()
        add_passover(timestamp=now - timedelta(seconds=10))
        for i in range(1, 20):
            p = add_passover(timestamp=now + timedelta(minutes=i * 5))

        db.session.commit()
예제 #3
0
파일: base.py 프로젝트: AlbertaSat/_ex2_
 def tearDown(self):
     db.session.remove()
     db.drop_all()
예제 #4
0
파일: base.py 프로젝트: AlbertaSat/_ex2_
 def tearDown(self):
     self.driver.quit()
     db.session.remove()
     db.drop_all()
예제 #5
0
def recreate_db():
    """Recreate the database
    """
    db.drop_all()
    db.create_all()
    db.session.commit()