Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
run all tests, add to README, update test_retriever
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Jan 5, 2024
1 parent 848bba4 commit 64d748b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
- name: Run pre-commit against all files
run: pre-commit run --all-files
- name: Run nose tests
run: nosetests httpobs/tests -e insert_test_result -e scored_test -e select_test_results -e test_retrieve --with-coverage --cover-package=httpobs
run: nosetests httpobs/tests --with-coverage --cover-package=httpobs
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ $ nano ~/.httpobs.conf
$ httpobs-server
```

### Running tests

```bash
$ nosetests httpobs/tests --with-coverage --cover-package=httpobs
```

## Running a scan from the local codebase, without DB, for continuous integration
```bash
# Install the HTTP Observatory
Expand Down
12 changes: 6 additions & 6 deletions httpobs/tests/unittests/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def test_retrieve_non_existent_domain(self):
self.assertEquals(domain, reqs['hostname'])
self.assertEquals({}, reqs['resources'])

def test_retrieve_mozilla(self):
reqs = retrieve_all('mozilla.org')
def test_retrieve_mdn(self):
reqs = retrieve_all('developer.mozilla.org')

# Various things we know about mozilla.org
# Various things we know about developer.mozilla.org
self.assertIsNotNone(reqs['resources']['__path__'])
self.assertIsNotNone(reqs['resources']['/contribute.json'])
self.assertIsNotNone(reqs['resources']['/robots.txt'])
Expand All @@ -38,12 +38,12 @@ def test_retrieve_mozilla(self):
self.assertIsInstance(reqs['responses']['https'], requests.Response)
self.assertIsInstance(reqs['session'], requests.Session)

self.assertEquals(reqs['hostname'], 'mozilla.org')
self.assertEquals(reqs['hostname'], 'developer.mozilla.org')

self.assertEquals('text/html', reqs['responses']['auto'].headers['Content-Type'][0:9])
self.assertEquals(2, len(reqs['responses']['auto'].history))
self.assertEquals(1, len(reqs['responses']['auto'].history))
self.assertEquals(200, reqs['responses']['auto'].status_code)
self.assertEquals('https://www.mozilla.org/en-US/', reqs['responses']['auto'].url)
self.assertEquals('https://developer.mozilla.org/en-US/', reqs['responses']['auto'].url)

def test_retrieve_invalid_cert(self):
reqs = retrieve_all('expired.badssl.com')
Expand Down

0 comments on commit 64d748b

Please sign in to comment.