def test_curve_doesnt_double_wrap(self): ec = CodeLine(graph=None, code='x = curve(<http://example/curve1>, t+.01)') _, inExpr, expr, uris = ec._asPython() self.assertEqual('curve(_res0, t+.01)', expr) self.assertEqual({'_res0': URIRef('http://example/curve1')}, uris)
def test_curve_uri_expands_to_curve_eval_func(self): ec = CodeLine(graph=None, code='x = <http://example/curve1>') _, inExpr, expr, uris = ec._asPython() self.assertEqual('curve(_res0, t)', expr) self.assertEqual({'_res0': URIRef('http://example/curve1')}, uris)
def test_doesnt_fall_for_brackets(self): ec = CodeLine(graph=None, code='x = 1<2>3< h') _, inExpr, expr, uris = ec._asPython() self.assertEqual('1<2>3< h', expr) self.assertEqual({}, uris)
def test_converts_multiple_uris(self): ec = CodeLine(graph=None, code='x = <http://example.com/> + <http://other>') _, inExpr, expr, uris = ec._asPython() self.assertEqual('_res0 + _res1', expr) self.assertEqual({'_res0': URIRef('http://example.com/'), '_res1': URIRef('http://other')}, uris)
def test_converts_uri_to_var(self): ec = CodeLine(graph=None, code='x = <http://example.com/>') _, inExpr, expr, uris = ec._asPython() self.assertEqual('_res0', expr) self.assertEqual({'_res0': URIRef('http://example.com/')}, uris)
def test_gets_simple_code(self): ec = CodeLine(graph=None, code='x = y+1') self.assertEqual('y+1', ec._asPython()[2]) self.assertEqual({}, ec._asPython()[3])