Merge pull request #33 from netzbegruenung/unittests

Unit tests und CI
This commit is contained in:
Marian Steinbach 2018-05-03 11:55:06 +02:00 committed by GitHub
commit cf656ad2d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 1 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ cache
webapp/node_modules
secrets
temp
__pycache__

10
.travis.yml Normal file
View File

@ -0,0 +1,10 @@
language: python
notifications:
email: false
install:
- make venv
script:
- make test

View File

@ -23,3 +23,6 @@ webapp: webapp/node_modules
serve-webapp:
cd docs && ../venv/bin/python -m http.server
test: venv
venv/bin/python ./test.py

View File

@ -105,7 +105,7 @@ def derive_test_hostnames(hostname):
else:
hostnames.add('www.' + hostname)
return list(hostnames)
return sorted(list(hostnames))
def reduce_urls(urllist):

17
test.py Normal file
View File

@ -0,0 +1,17 @@
import unittest
import spider
class TestSpider(unittest.TestCase):
def test_derive_test_hostnames1(self):
hn = spider.derive_test_hostnames('www.my-domain.de')
expected = ['my-domain.de', 'www.my-domain.de']
self.assertEqual(hn, expected)
def test_derive_test_hostnames2(self):
hn = spider.derive_test_hostnames('domain.de')
expected = ['domain.de', 'www.domain.de']
self.assertEqual(hn, expected)
if __name__ == '__main__':
unittest.main()