Skip to content

Improve tests #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
- run:
name: run tox
command: ~/.local/bin/tox
- store_artifacts:
path: test/artifacts
- add_ssh_keys:
fingerprints:
- "79:16:39:74:e9:b3:39:52:87:2c:90:aa:ee:3c:09:13"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ stdout*
/integration*
.idea/
docs/_build/

test/artifacts/*
!test/artifacts/.gitkeep
.tox
Empty file added test/artifacts/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion test/fixtures/integration/config-linestring.geojson.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{"name": "residential", "filter": ["in", "highway", "residential"]},
{"name": "unclassified", "filter": ["in", "highway", "unclassified"]}
],
"geojson": "/Users/marthamorrissey/repos/label-maker/test/fixtures/integration/labels-linestring.geojson",
"geojson": "integration-cl/labels-linestring.geojson",
"imagery": "https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.jpg?access_token=ACCESS_TOKEN",
"background_ratio": 1,
"split_vals": [1.0, 0.0, 0.0],
Expand Down
6 changes: 5 additions & 1 deletion test/integration/test_classification_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
label-maker labels --dest integration-cl --config test/fixtures/integration/config.integration.json"""
import unittest
import json
import os
from os import makedirs
from shutil import copyfile, rmtree
import subprocess
Expand Down Expand Up @@ -37,7 +38,10 @@ def test_cli(self):
cmd = 'label-maker labels --dest integration-cl --config test/fixtures/integration/config.integration.json'
cmd = cmd.split(' ')
with subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE) as p:
self.assertEqual(expected_output, p.stdout.read())
with open(os.path.join('test' ,'artifacts', type(self).__name__), 'w') as w:
output = p.stdout.read()
w.write(output)
self.assertEqual(expected_output, output)

# our labels should look like this
expected_labels = {
Expand Down
6 changes: 5 additions & 1 deletion test/integration/test_classification_labels_geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
label-maker labels --dest integration-cl --config test/fixtures/integration/config.geojson.json"""
import unittest
import json
import os
from os import makedirs
from shutil import copyfile, rmtree
import subprocess
Expand Down Expand Up @@ -37,7 +38,10 @@ def test_cli(self):
cmd = 'label-maker labels --dest integration-cl --config test/fixtures/integration/config.geojson.json'
cmd = cmd.split(' ')
with subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE) as p:
self.assertEqual(expected_output, p.stdout.read())
with open(os.path.join('test' ,'artifacts', type(self).__name__), 'w') as w:
output = p.stdout.read()
w.write(output)
self.assertEqual(expected_output, output)

# our labels should look like this
expected_labels = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
label-maker labels --dest integration-cl --config test/fixtures/integration/config.geojson.json"""
import unittest
import json
import os
from os import makedirs
from shutil import copyfile, rmtree
import subprocess

import numpy as np

class TestClassificationLabelGeoJSON(unittest.TestCase):
class TestClassificationLabelLineStringGeoJSON(unittest.TestCase):
"""Tests for classification label creation"""
@classmethod
def setUpClass(cls):
makedirs('integration-cl')
copyfile('test/fixtures/integration/labels-linestring.geojson', 'integration-cl/labels.geojson')
copyfile('test/fixtures/integration/labels-linestring.geojson', 'integration-cl/labels-linestring.geojson')

@classmethod
def tearDownClass(cls):
Expand All @@ -37,7 +38,10 @@ def test_cli(self):
cmd = 'label-maker labels --dest integration-cl --config test/fixtures/integration/config-linestring.geojson.json'
cmd = cmd.split(' ')
with subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE) as p:
self.assertEqual(expected_output, p.stdout.read())
with open(os.path.join('test' ,'artifacts', type(self).__name__), 'w') as w:
output = p.stdout.read()
w.write(output)
self.assertEqual(expected_output, output)

# our labels should look like this

Expand Down
6 changes: 5 additions & 1 deletion test/integration/test_classification_labels_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
label-maker labels --dest integration-cl --config test/fixtures/integration/config.integration_sparse.json --sparse"""
import unittest
import json
import os
from os import makedirs
from shutil import copyfile, rmtree
import subprocess
Expand Down Expand Up @@ -38,7 +39,10 @@ def test_cli(self):
cmd = 'label-maker labels --dest integration-cl --config test/fixtures/integration/config.integration_sparse.json --sparse'
cmd = cmd.split(' ')
with subprocess.Popen(cmd, universal_newlines=True, stdout=subprocess.PIPE) as p:
self.assertEqual(expected_output, p.stdout.read())
with open(os.path.join('test' ,'artifacts', type(self).__name__), 'w') as w:
output = p.stdout.read()
w.write(output)
self.assertEqual(expected_output, output)

# our labels should look like this
expected_labels = {
Expand Down
Binary file added test/tiles/1087767-1046604-21.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/tiles/146-195-9.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.