Example #1
0
 def setUp(self):
     self.app = create_app('testing')
     self.ctx = self.app.app_context()
     self.ctx.push()
     db.drop_all()  # just in case
     db.create_all()
     self.client = self.app.test_client()
Example #2
0
File: tests.py Project: QsBBQ/flack
    def setUp(self):
        self.app = create_app('testing')

        # add an additional route used only in tests
        @self.app.route('/foo')
        @async
        def foo():
            1 / 0

        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()  # just in case
        db.create_all()
        self.client = self.app.test_client()
Example #3
0
    def setUp(self):
        self.app = create_app('testing')

        # add an additional route used only in tests
        @self.app.route('/foo')
        @async
        def foo():
            1 / 0

        self.ctx = self.app.app_context()
        self.ctx.push()
        db.drop_all()  # just in case
        db.create_all()
        self.client = self.app.test_client()
Example #4
0
def createdb(drop_first=False):
    """Creates the database."""
    if drop_first:
        db.drop_all()
    db.create_all()
Example #5
0
File: tests.py Project: QsBBQ/flack
 def tearDown(self):
     db.drop_all()
     self.ctx.pop()
Example #6
0
 def tearDown(self):
     db.drop_all()
     self.ctx.pop()
Example #7
0
File: manage.py Project: jm66/flack
def createdb(drop_first=False):
    """Creates the database."""
    if drop_first:
        db.drop_all()
    db.create_all()
Example #8
0
 def tearDown(self):
     db.drop_all()
Example #9
0
 def setUp(self):
     db.drop_all()  # just in case
     db.create_all()
     self.client = app.test_client()
Example #10
0
def createdb(drop_first=False):
    #creates the database
    if drop_first:
        db.drop_all()
    db.create_all()
Example #11
0
 def tearDown(self):
     db.drop_all()
Example #12
0
 def setUp(self):
     db.drop_all()  # just in case
     db.create_all()
     self.client = app.test_client()
Example #13
0
def bootstrap_data():
    db.drop_all()
    print("database dropped")
    db.create_all()
    print("database created")
    u1 = User(username='******', email="*****@*****.**")
    u1.password = generate_password_hash(password="******")
    u2 = User(username='******', email="*****@*****.**")
    u2.password = generate_password_hash(password="******")
    u3 = User(username='******', email="*****@*****.**")
    u3.password = generate_password_hash(password="******")
    c1 = Channel(name="General", private="false")
    c2 = Channel(name="Random", private="false")
    c3 = Channel(name="Labs", private="true")
    m1 = Message(content="Hey everyone, this is a message")
    m2 = Message(content="Hey ladies and gents, this is a second message")
    m3 = Message(content="Hey pythonistas, this is a third message")
    w1 = Workspace(name="Flack Workspace", description="The First Workspace")
    db.session.add(u1)
    db.session.add(u2)
    db.session.add(u3)
    db.session.add(c1)
    db.session.add(c2)
    db.session.add(c3)
    db.session.add(m1)
    db.session.add(m2)
    db.session.add(m3)
    db.session.add(w1)
    #assign users to channel
    c1.users.extend((u1, u2, u3))
    #assign workspaces to users
    u1.workspaces.append(w1)
    u2.workspaces.append(w1)
    u3.workspaces.append(w1)
    #add channels to workspace
    w1.channels.extend((c1, c2, c3))
    #assign messages to users
    u1.messages.append(m1)
    u2.messages.append(m2)
    u3.messages.append(m3)
    #add messagees to channel 1
    c1.messages.append(m3)
    c1.messages.append(m2)
    c1.messages.append(m1)

    log1 = Log(ip_address="0.0.0.0", time=datetime.now(), success=True)
    db.session.add(log1)

    db.session.commit()

    #test database queries
    w1_channels = w1.channels
    #get each channel
    for i in w1_channels:
        print(i.name)
        #print the users in each channel
        x = i.users
        for z in x:
            print("\t" + z.username)
    #find the workspaces and channels for a particular user
    user1_workspace = u1.workspaces
    for workspace in user1_workspace:
        print(workspace.name)
        for channel in workspace.channels:
            print(channel.name)