Skip to content

Commit

Permalink
fix(api): Change api update ignore route to be accessible to client
Browse files Browse the repository at this point in the history
Closes #2367
  • Loading branch information
btmorr committed Sep 26, 2018
1 parent 4744e53 commit 1e9930d
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 44 deletions.
3 changes: 1 addition & 2 deletions api/opentrons/server/endpoints/serverlib_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from threading import Thread

log = logging.getLogger(__name__)
PATH = os.path.abspath(os.path.dirname(__file__))
filepath = os.path.join(PATH, 'ignore.json')
filepath = '/data/user_storage/opentrons_data/ignore.json'


async def _install(filename, loop):
Expand Down
4 changes: 2 additions & 2 deletions api/opentrons/server/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def __init__(self, app, log_file_path):
self.app.router.add_post(
'/modules/{serial}/update', update.update_module_firmware)
self.app.router.add_get(
'/server/update/ignore', endpoints.get_ignore_version)
'/update/ignore', endpoints.get_ignore_version)
self.app.router.add_post(
'/server/update/ignore', endpoints.set_ignore_version)
'/update/ignore', endpoints.set_ignore_version)
self.app.router.add_static(
'/logs', self.log_file_path, show_index=True)
self.app.router.add_post(
Expand Down
6 changes: 3 additions & 3 deletions api/tests/opentrons/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def robot(dummy_db):
@pytest.fixture(params=["dinosaur.py"])
def protocol(request):
try:
root = request.getfuncargvalue('protocol_file')
root = request.getfixturevalue('protocol_file')
except Exception:
root = request.param

Expand All @@ -226,7 +226,7 @@ def protocol(request):
@pytest.fixture(params=["no_clear_tips.py"])
def tip_clear_protocol(request):
try:
root = request.getfuncargvalue('protocol_file')
root = request.getfixturevalue('protocol_file')
except Exception:
root = request.param

Expand All @@ -253,7 +253,7 @@ def session(loop, test_client, request, main_router):
from opentrons.server import error_middleware
root = None
try:
root = request.getfuncargvalue('root')
root = request.getfixturevalue('root')
if not root:
root = main_router
# Assume test fixture has init to attach test loop
Expand Down
6 changes: 3 additions & 3 deletions api/tests/opentrons/containers/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_load_same_slot_force(self):
slot = '1'
containers_load(self.robot, container_name, slot)
# 2018-1-30 Incremented number of containers based on fixed trash
self.assertEquals(len(self.robot.get_containers()), 2)
self.assertEqual(len(self.robot.get_containers()), 2)

self.assertRaises(
RuntimeWarning, containers_load,
Expand All @@ -47,11 +47,11 @@ def test_load_same_slot_force(self):

containers_load(
self.robot, container_name, slot, 'custom-name', share=True)
self.assertEquals(len(self.robot.get_containers()), 3)
self.assertEqual(len(self.robot.get_containers()), 3)

containers_load(
self.robot, 'trough-12row', slot, share=True)
self.assertEquals(len(self.robot.get_containers()), 4)
self.assertEqual(len(self.robot.get_containers()), 4)

def test_load_legacy_slot_names(self):
slots_old = [
Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/containers/test_old_container_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ def test_load_all_containers(self):
old_container_loading.get_persisted_container("container-2")

# Skip container-3 is defined in .secret/containers-3.json.
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError,
'Container type "container-3" not found in files: .*'
):
old_container_loading.get_persisted_container("container-3")

# Skip container-4 is defined in .containers-4.json.
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError,
'Container type "container-4" not found in files: .*'
):
Expand Down
2 changes: 1 addition & 1 deletion api/tests/opentrons/containers/test_placeable_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def assertWellSeriesEqual(self, w1, w2):
print(w2)
assert False
else:
self.assertEquals(w1, w2)
self.assertEqual(w1, w2)

def test_get_name(self):
c = generate_plate(4, 2, (5, 5), (0, 0), 5)
Expand Down
8 changes: 4 additions & 4 deletions api/tests/opentrons/helpers/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def test_break_down_travel(self):
p2 = Vector(10, -12, 14)
res = helpers.break_down_travel(
p1, p2, increment=5, mode='absolute')
self.assertEquals(res[-1], p2)
self.assertEquals(len(res), 5)
self.assertEqual(res[-1], p2)
self.assertEqual(len(res), 5)

p1 = Vector(10, -12, 14)
res = helpers.break_down_travel(Vector(0, 0, 0), p1, mode='relative')
expected = Vector(
0.46537410754407676,
-0.5584489290528921,
0.6515237505617075)
self.assertEquals(res[-1], expected)
self.assertEquals(len(res), 5)
self.assertEqual(res[-1], expected)
self.assertEqual(len(res), 5)
42 changes: 21 additions & 21 deletions api/tests/opentrons/labware/test_pipette_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def test_aspirate_zero_volume(self):

def test_get_plunger_position(self):

self.assertEquals(self.p200._get_plunger_position('top'), 0)
self.assertEquals(self.p200._get_plunger_position('bottom'), 10)
self.assertEquals(self.p200._get_plunger_position('blow_out'), 12)
self.assertEquals(self.p200._get_plunger_position('drop_tip'), 13)
self.assertEqual(self.p200._get_plunger_position('top'), 0)
self.assertEqual(self.p200._get_plunger_position('bottom'), 10)
self.assertEqual(self.p200._get_plunger_position('blow_out'), 12)
self.assertEqual(self.p200._get_plunger_position('drop_tip'), 13)

self.p200.plunger_positions['drop_tip'] = None
self.assertRaises(
Expand Down Expand Up @@ -112,7 +112,7 @@ def test_placeables_reference(self):
self.plate[1]
]

self.assertEquals(self.p200.placeables, expected)
self.assertEqual(self.p200.placeables, expected)

def test_unpack_location(self):

Expand All @@ -133,10 +133,10 @@ def test_aspirate_invalid_max_volume(self):
def test_volume_percentage(self):
self.assertRaises(RuntimeError, self.p200._volume_percentage, -1)
self.assertRaises(RuntimeError, self.p200._volume_percentage, 300)
self.assertEquals(self.p200._volume_percentage(100), 0.5)
self.assertEquals(len(self.robot.get_warnings()), 0)
self.assertEqual(self.p200._volume_percentage(100), 0.5)
self.assertEqual(len(self.robot.get_warnings()), 0)
self.p200._volume_percentage(self.p200.min_volume / 2)
self.assertEquals(len(self.robot.get_warnings()), 1)
self.assertEqual(len(self.robot.get_warnings()), 1)

def test_add_tip(self):
"""
Expand Down Expand Up @@ -922,7 +922,7 @@ def test_touch_tip(self):
strategy='direct')
]

self.assertEquals(expected, self.p200.robot.move_to.mock_calls)
self.assertEqual(expected, self.p200.robot.move_to.mock_calls)

def test_mix(self):
# It is necessary to aspirate before it is mocked out
Expand Down Expand Up @@ -950,26 +950,26 @@ def test_air_gap(self):
self.p200.pick_up_tip()
self.p200.aspirate(50, self.plate[0])
self.p200.air_gap()
self.assertEquals(self.p200.current_volume, 200)
self.assertEqual(self.p200.current_volume, 200)

self.p200.dispense()
self.p200.aspirate(50, self.plate[1])
self.p200.air_gap(10)
self.assertEquals(self.p200.current_volume, 60)
self.assertEqual(self.p200.current_volume, 60)

self.p200.dispense()
self.p200.aspirate(50, self.plate[2])
self.p200.air_gap(10, 10)
self.assertEquals(self.p200.current_volume, 60)
self.assertEqual(self.p200.current_volume, 60)

self.p200.dispense()
self.p200.aspirate(50, self.plate[2])
self.p200.air_gap(0)
self.assertEquals(self.p200.current_volume, 50)
self.assertEqual(self.p200.current_volume, 50)

def test_pipette_home(self):
self.p200.home()
self.assertEquals(len(self.robot.commands()), 1)
self.assertEqual(len(self.robot.commands()), 1)

def test_mix_with_named_args(self):
self.p200.current_volume = 100
Expand Down Expand Up @@ -1008,22 +1008,22 @@ def test_tip_tracking_simple(self):
def test_simulate_plunger_while_enqueing(self):

self.p200.pick_up_tip()
self.assertEquals(self.p200.current_volume, 0)
self.assertEqual(self.p200.current_volume, 0)

self.p200.aspirate(200)
self.assertEquals(self.p200.current_volume, 200)
self.assertEqual(self.p200.current_volume, 200)

self.p200.dispense(20)
self.assertEquals(self.p200.current_volume, 180)
self.assertEqual(self.p200.current_volume, 180)

self.p200.dispense(20)
self.assertEquals(self.p200.current_volume, 160)
self.assertEqual(self.p200.current_volume, 160)

self.p200.dispense(60)
self.assertEquals(self.p200.current_volume, 100)
self.assertEqual(self.p200.current_volume, 100)

self.p200.dispense(100)
self.assertEquals(self.p200.current_volume, 0)
self.assertEqual(self.p200.current_volume, 0)

self.p200.drop_tip()

Expand Down Expand Up @@ -1113,7 +1113,7 @@ def test_tip_tracking_chain_multi_channel(self):
def test_tip_tracking_start_at_tip(self):
self.p200.start_at_tip(self.tiprack1['B2'])
self.p200.pick_up_tip()
self.assertEquals(self.tiprack1['B2'], self.p200.current_tip())
self.assertEqual(self.tiprack1['B2'], self.p200.current_tip())

def test_tip_tracking_return(self):
# Note: because this test mocks out `drop_tip`, as a side-effect
Expand Down
8 changes: 4 additions & 4 deletions api/tests/opentrons/server/test_update_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ async def test_ignore_updates(
app = init(loop)
cli = await loop.create_task(test_client(app))
# Test no ignore file found
r0 = await cli.get('/server/update/ignore')
r0 = await cli.get('/update/ignore')
r0body = await r0.text()
assert json.loads(r0body) == {'version': None}

# Test that values are set correctly

ignore = {'version': '3.1.3'}
r1 = await cli.post('server/update/ignore', json=ignore)
r1 = await cli.post('/update/ignore', json=ignore)
assert r1.status == 200

# Test that you cannot pass an empty version
ignore2 = {'version': ''}
r2 = await cli.post('server/update/ignore', json=ignore2)
r2 = await cli.post('/update/ignore', json=ignore2)
assert r2.status == 400

# Test that version in the temporary directory is still '3.1.3'
r3 = await cli.get('/server/update/ignore')
r3 = await cli.get('/update/ignore')
r3body = await r3.text()
assert json.loads(r3body) == {'version': '3.1.3'}

Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/util/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_init(self):

def test_repr(self):
v1 = Vector(1, 2, 3)
self.assertEquals(str(v1), '(x=1.00, y=2.00, z=3.00)')
self.assertEqual(str(v1), '(x=1.00, y=2.00, z=3.00)')

def test_add(self):
v1 = Vector(1, 2, 3)
Expand All @@ -38,7 +38,7 @@ def test_to_iterable(self):
def test_zero_coordinates(self):

zero_coords = Vector(1, 2, 3).zero_coordinates()
self.assertEquals(zero_coords, VectorValue(0, 0, 0))
self.assertEqual(zero_coords, VectorValue(0, 0, 0))

def test_substract(self):
v1 = Vector(1, 2, 3)
Expand Down

0 comments on commit 1e9930d

Please sign in to comment.