Пример #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')
Пример #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')
Пример #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
Пример #4
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
Пример #5
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'
Пример #6
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'