Skip to content

Commit

Permalink
Merge pull request #56 from KOSASIH/deepsource-transform-cea24169
Browse files Browse the repository at this point in the history
style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf
  • Loading branch information
KOSASIH authored May 11, 2024
2 parents 9818abb + cf14607 commit b08a571
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tests/test_web.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Web test file
import unittest

from app import app, db
from app.models import User, File
from app.models import File, User


class TestWeb(unittest.TestCase):
def setUp(self):
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
app.config["TESTING"] = True
app.config["WTF_CSRF_ENABLED"] = False
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
self.client = app.test_client()
db.create_all()

Expand All @@ -16,24 +18,27 @@ def tearDown(self):
db.drop_all()

def test_index(self):
response = self.client.get('/')
response = self.client.get("/")
self.assertEqual(response.status_code, 200)

def test_upload_file(self):
response = self.client.post('/upload', data={
'username': 'test_user',
'file': ('test_file.txt', 'test_file.txt')
})
response = self.client.post(
"/upload",
data={"username": "test_user", "file": ("test_file.txt", "test_file.txt")},
)
self.assertEqual(response.status_code, 302)
self.assertTrue(File.query.count() > 0)

def test_file_list(self):
file = File(name='test_file.txt', content='test_hash', user=User(username='test_user'))
file = File(
name="test_file.txt", content="test_hash", user=User(username="test_user")
)
db.session.add(file)
db.session.commit()
response = self.client.get('/files')
response = self.client.get("/files")
self.assertEqual(response.status_code, 200)
self.assertIn(b'test_file.txt', response.data)
self.assertIn(b"test_file.txt", response.data)


if __name__ == '__main__':
if __name__ == "__main__":
unittest.main()

0 comments on commit b08a571

Please sign in to comment.