Beispiel #1
0
def testSliceSimpleAsciiStlField():
    fields = [ ('stl', testtools.dataFile('trivial_ascii.stl')) ]
    response = testtools.postRequest(baseurl+'/slice', fields=fields)

    testtools.assertEqual(response.status_code, 200)
    r = response.read()
    lines = r.split('\n')
    assert len(lines) > 1000
    assert lines[0].startswith('M109 T0')
Beispiel #2
0
def testSliceSimpleAsciiStlField():
    fields = [('stl', testtools.dataFile('trivial_ascii.stl'))]
    response = testtools.postRequest(baseurl + '/slice', fields=fields)

    testtools.assertEqual(response.status_code, 200)
    r = response.read()
    lines = r.split('\n')
    assert len(lines) > 1000
    assert lines[0].startswith('M109 T0')
Beispiel #3
0
def testSliceInvalidStlFile():
    files = [('stl', 'invalid.stl', testtools.dataFile('invalid.stl'))]
    response = testtools.postRequest(baseurl + '/slice', files)

    testtools.assertEqual(response.status_code, 400)
    content_type = testtools.getHeader(response, 'content-type')
    testtools.assertEqual(content_type, 'application/json')
    res = json.loads(response.read())
    assert res['error']
    assert len(res['error']) > 10
Beispiel #4
0
def testMissingStl():
    files = []
    response = testtools.postRequest(baseurl + '/slice', files)

    testtools.assertEqual(response.status_code, 400)
    content_type = testtools.getHeader(response, 'content-type')
    testtools.assertEqual(content_type, 'application/json')
    res = json.loads(response.read())
    assert res['error']
    assert len(res['error']) > 10
Beispiel #5
0
def testSliceInvalidStlFile():
    files = [ ('stl', 'invalid.stl', testtools.dataFile('invalid.stl')) ]
    response = testtools.postRequest(baseurl+'/slice', files)

    testtools.assertEqual(response.status_code, 400)
    content_type = testtools.getHeader(response, 'content-type')
    testtools.assertEqual(content_type, 'application/json')
    res = json.loads(response.read())
    assert res['error']
    assert len(res['error']) > 10
Beispiel #6
0
def testMissingStl():
    files = []
    response = testtools.postRequest(baseurl+'/slice', files)

    testtools.assertEqual(response.status_code, 400)
    content_type = testtools.getHeader(response, 'content-type')
    testtools.assertEqual(content_type, 'application/json')
    res = json.loads(response.read())
    assert res['error']
    assert len(res['error']) > 10
Beispiel #7
0
def testPreviewSimpleAsciiStlField():
    fields = [ ('stl', testtools.dataFile('trivial_ascii.stl')) ]
    response = testtools.postRequest(baseurl+'/preview', fields=fields)

    testtools.assertEqual(response.status_code, 200)
    r = json.loads(response.read())
    assert r['gcode'].startswith('M109 T0')
    assert len(r['polygons']) == 198
    assert r['polygons'][0].keys() == [u'openoutline', u'inset0', u'skirt', u'insetx', u'skin']
    assert r['filamentUse'] == '0.48 meter 4 gram'
    assert r['printTime'] == '28 minutes'
Beispiel #8
0
def testPreviewSimpleAsciiStlField():
    fields = [('stl', testtools.dataFile('trivial_ascii.stl'))]
    response = testtools.postRequest(baseurl + '/preview', fields=fields)

    testtools.assertEqual(response.status_code, 200)
    r = json.loads(response.read())
    assert r['gcode'].startswith('M109 T0')
    assert len(r['polygons']) == 198
    assert r['polygons'][0].keys() == [
        u'openoutline', u'inset0', u'skirt', u'insetx', u'skin'
    ]
    assert r['filamentUse'] == '0.48 meter 4 gram'
    assert r['printTime'] == '28 minutes'