From 0595a2853547ac5128a3eb01c5e32c508cac7a20 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 10 Jul 2018 12:05:03 +0200 Subject: [PATCH] Add the first test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It just checks if the index page has a specific sentence. But at least it’s now possible to create tests. --- .gitignore | 1 + Pipfile | 1 + Pipfile.lock | 58 ++++++++++++++++++++++++++++++++++++++--- tests/test_calsocial.py | 24 +++++++++++++++++ 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 tests/test_calsocial.py diff --git a/.gitignore b/.gitignore index f97f5ad..4bdd594 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ /calsocial/local.db /messages.pot /app/translations/*/LC_MESSAGES/*.mo +/.pytest_cache/ diff --git a/Pipfile b/Pipfile index 0df03ea..8191b37 100644 --- a/Pipfile +++ b/Pipfile @@ -16,6 +16,7 @@ python-dateutil = "*" [dev-packages] pylint = "*" +pytest = "*" [requires] python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock index 83f8e02..1b17f2b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "87b2f3f49611403e69ea47ebc364bf471ab966577dcf0f813087fe7f386bc75e" + "sha256": "3620d7a03e2f49bbf1b812fee29e163e2e0120cd1a3924f6895d3194583e7ac7" }, "pipfile-spec": 6, "requires": { @@ -37,7 +37,9 @@ "sha256:3b4c23300c4eded8895442c003ae9b14328ae69309ac5867e7530de8bdd7875d", "sha256:43d1960e7db14042319c46925892d5fa99b08ff21d57482e6f5328a1aca03588", "sha256:49e96267cd9be55a349fd74f9852eb9ae2c427cd7f6455d0f1765d7332292832", + "sha256:63e06ffdaf4054a89757a3a1ab07f1b922daf911743114a54f7c561b9e1baa58", "sha256:67ed1a374c9155ec0840214ce804616de49c3df9c5bc66740687c1c9b1cd9e8d", + "sha256:6b662a5669186439f4f583636c8d6ea77cf92f7cfe6aae8d22edf16c36840574", "sha256:6efd9ca20aefbaf2e7e6817a2c6ed4a50ff6900fafdea1bcb1d0e9471743b144", "sha256:8569844a5d8e1fdde4d7712a05ab2e6061343ac34af6e7e3d7935b2bd1907bfd", "sha256:8629ea6a8a59f865add1d6a87464c3c676e60101b8d16ef404d0a031424a8491", @@ -49,9 +51,12 @@ "sha256:b1e8491c6740f21b37cca77bc64677696a3fb9f32360794d57fa8477b7329eda", "sha256:c906bdb482162e9ef48eea9f8c0d967acceb5c84f2d25574c7d2a58d04861df1", "sha256:cb18ffdc861dbb244f14be32c47ab69604d0aca415bee53485fcea4f8e93d5ef", + "sha256:cc2f24dc1c6c88c56248e93f28d439ee4018338567b0bbb490ea26a381a29b1e", + "sha256:d860c7fff18d49e20339fc6dffc2d485635e36d4b2cccf58f45db815b64100b4", "sha256:d86da365dda59010ba0d1ac45aa78390f56bf7f992e65f70b3b081d5e5257b09", "sha256:e22f0997622e1ceec834fd25947dc2ee2962c2133ea693d61805bc867abaf7ea", "sha256:f2fe545d27a619a552396533cddf70d83cecd880a611cdfdbb87ca6aec52f66b", + "sha256:f425e925485b3be48051f913dbe17e08e8c48588fdf44a26b8b14067041c0da6", "sha256:f7fd3ed3745fe6e81e28dc3b3d76cce31525a91f32a387e1febd6b982caf8cdb", "sha256:f9210820ee4818d84658ed7df16a7f30c9fba7d8b139959950acef91745cc0f7" ], @@ -166,11 +171,11 @@ }, "gunicorn": { "hashes": [ - "sha256:7ef2b828b335ed58e3b64ffa84caceb0a7dd7c5ca12f217241350dec36a1d5dc", - "sha256:bc59005979efb6d2dd7d5ba72d99f8a8422862ad17ff3a16e900684630dd2a10" + "sha256:aa8e0b40b4157b36a5df5e599f45c9c76d6af43845ba3b3b0efe2c70473c2471", + "sha256:fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3" ], "index": "pypi", - "version": "==19.8.1" + "version": "==19.9.0" }, "itsdangerous": { "hashes": [ @@ -276,6 +281,20 @@ ], "version": "==1.6.5" }, + "atomicwrites": { + "hashes": [ + "sha256:240831ea22da9ab882b551b31d4225591e5e447a68c5e188db5b89ca1d487585", + "sha256:a24da68318b08ac9c9c45029f4a10371ab5b20e4226738e150e6e7c571630ae6" + ], + "version": "==1.1.5" + }, + "attrs": { + "hashes": [ + "sha256:4b90b09eeeb9b88c35bc642cbac057e45a5fd85367b985bd2809c62b7b939265", + "sha256:e0d0eb91441a3b53dab4d9b743eafc1ac44476296a2053b6ca3af0b139faf87b" + ], + "version": "==18.1.0" + }, "isort": { "hashes": [ "sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af", @@ -325,6 +344,29 @@ ], "version": "==0.6.1" }, + "more-itertools": { + "hashes": [ + "sha256:2b6b9893337bfd9166bee6a62c2b0c9fe7735dcf85948b387ec8cba30e85d8e8", + "sha256:6703844a52d3588f951883005efcf555e49566a48afd4db4e965d69b883980d3", + "sha256:a18d870ef2ffca2b8463c0070ad17b5978056f403fb64e3f15fe62a52db21cc0" + ], + "version": "==4.2.0" + }, + "pluggy": { + "hashes": [ + "sha256:7f8ae7f5bdf75671a718d2daf0a64b7885f74510bcd98b1a0bb420eb9a9d0cff", + "sha256:d345c8fe681115900d6da8d048ba67c25df42973bda370783cd58826442dcd7c", + "sha256:e160a7fcf25762bb60efc7e171d4497ff1d8d2d75a3d0df7a21b76821ecbf5c5" + ], + "version": "==0.6.0" + }, + "py": { + "hashes": [ + "sha256:3fd59af7435864e1a243790d322d763925431213b6b8529c6ca71081ace3bbf7", + "sha256:e31fb2767eb657cbde86c454f02e99cb846d3cd9d61b318525140214fdc0e98e" + ], + "version": "==1.5.4" + }, "pylint": { "hashes": [ "sha256:a48070545c12430cfc4e865bf62f5ad367784765681b3db442d8230f0960aa3c", @@ -333,6 +375,14 @@ "index": "pypi", "version": "==1.9.2" }, + "pytest": { + "hashes": [ + "sha256:0453c8676c2bee6feb0434748b068d5510273a916295fd61d306c4f22fbfd752", + "sha256:4b208614ae6d98195430ad6bde03641c78553acee7c83cec2e85d613c0cd383d" + ], + "index": "pypi", + "version": "==3.6.3" + }, "six": { "hashes": [ "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9", diff --git a/tests/test_calsocial.py b/tests/test_calsocial.py new file mode 100644 index 0000000..c664615 --- /dev/null +++ b/tests/test_calsocial.py @@ -0,0 +1,24 @@ +import pytest + +import calsocial +from calsocial.models import db + + +@pytest.fixture +def client(): + calsocial.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + calsocial.app.config['TESTING'] = True + client = calsocial.app.test_client() + + with calsocial.app.app_context(): + db.create_all() + + yield client + + +def test_index_no_login(client): + """Test the main page without logging in + """ + + page = client.get('/') + assert b'Welcome to Calendar.social' in page.data