Exemple #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()
Exemple #2
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()
Exemple #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()
Exemple #4
0
def createdb(drop_first=False):
    """Creates the database."""
    if drop_first:
        db.drop_all()
    db.create_all()
Exemple #5
0
 def tearDown(self):
     db.drop_all()
     self.ctx.pop()
Exemple #6
0
 def tearDown(self):
     db.drop_all()
     self.ctx.pop()
Exemple #7
0
def createdb(drop_first=False):
    """Creates the database."""
    if drop_first:
        db.drop_all()
    db.create_all()
Exemple #8
0
 def tearDown(self):
     db.drop_all()
Exemple #9
0
 def setUp(self):
     db.drop_all()  # just in case
     db.create_all()
     self.client = app.test_client()
Exemple #10
0
def createdb(drop_first=False):
    #creates the database
    if drop_first:
        db.drop_all()
    db.create_all()
Exemple #11
0
 def tearDown(self):
     db.drop_all()
Exemple #12
0
 def setUp(self):
     db.drop_all()  # just in case
     db.create_all()
     self.client = app.test_client()
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)