Beispiel #1
0
def test_format_accepts_encoding():  # issue20
    sql = load_file('test_cp1251.sql', 'cp1251')
    formatted = sqlparse.format(sql, reindent=True, encoding='cp1251')
    if sys.version_info < (3, ):
        tformatted = u'insert into foo\nvalues (1); -- Песня про надежду\n'
    else:
        tformatted = 'insert into foo\nvalues (1); -- Песня про надежду\n'
    assert formatted == tformatted
def test_format_accepts_encoding():  # issue20
    sql = load_file('test_cp1251.sql', 'cp1251')
    formatted = sqlparse.format(sql, reindent=True, encoding='cp1251')
    if sys.version_info < (3,):
        tformatted = u'insert into foo\nvalues (1); -- Песня про надежду\n'
    else:
        tformatted = 'insert into foo\nvalues (1); -- Песня про надежду\n'
    assert formatted == tformatted
Beispiel #3
0
 def test_yaml_simple_outputfile(fixture_tmpdir, fixture_clicker):
     """
     python3 -mas3ninja transform -c examples/simple/ninja.yaml -t examples/simple/template.j2 -o /tmp/output.json
     """
     tmpdir = fixture_tmpdir
     result = fixture_clicker.invoke(
         cli,
         [
             "transform",
             "-c",
             "examples/simple/ninja.yaml",
             "-t",
             "examples/simple/template.j2",
             "-o",
             f"{tmpdir}/output.json",
         ],
     )
     assert result.exit_code == 0
     assert format_json(load_file(f"{tmpdir}/output.json")) == format_json(
         load_file("examples/simple/declaration.json"))
Beispiel #4
0
 def test_yaml_simple_longoptions(fixture_clicker):
     """
     python3 -mas3ninja transform --configuration-file examples/simple/ninja.yaml --declaration-template examples/simple/template.j2
     """
     result = fixture_clicker.invoke(
         cli,
         [
             "transform",
             "--configuration-file",
             "examples/simple/ninja.yaml",
             "--declaration-template",
             "examples/simple/template.j2",
         ],
     )
     assert result.exit_code == 0
     assert format_json(result.output) == format_json(
         load_file("examples/simple/declaration.json"))
Beispiel #5
0
 def test_yaml_pretty_print(fixture_clicker):
     """
     python3 -mas3ninja transform --pretty --no-validate -c examples/yaml_datatypes/config.yaml -t examples/yaml_datatypes/template.j2
     """
     result = fixture_clicker.invoke(
         cli,
         [
             "transform",
             "--pretty",
             "--no-validate",
             "-c",
             "examples/yaml_datatypes/config.yaml",
             "-t",
             "examples/yaml_datatypes/template.j2",
         ],
     )
     assert result.exit_code == 0
     assert result.output == load_file("examples/yaml_datatypes/output.json")
Beispiel #6
0
 def test_yaml_simple_configoverlay(fixture_clicker):
     """
     python3 -mas3ninja transform -c examples/simple/ninja.yaml -c examples/simple/overlay.json -t examples/simple/template.j2
     """
     result = fixture_clicker.invoke(
         cli,
         [
             "transform",
             "-c",
             "examples/simple/ninja.yaml",
             "-c",
             "examples/simple/overlay.json",
             "-t",
             "examples/simple/template.j2",
         ],
     )
     assert result.exit_code == 0
     assert format_json(result.output) == format_json(
         load_file("examples/simple/declaration_with_overlay.json"))
Beispiel #7
0
 def test_yaml_datatypes(fixture_clicker):
     """
     python3 -mas3ninja transform --no-validate -c examples/yaml_datatypes/config.yaml -t examples/yaml_datatypes/template.j2
     """
     result = fixture_clicker.invoke(
         cli,
         [
             "transform",
             "--no-validate",
             "-c",
             "examples/yaml_datatypes/config.yaml",
             "-t",
             "examples/yaml_datatypes/template.j2",
         ],
     )
     assert result.exit_code == 0
     print(f"\n\nresult.output:{result.output}\n\n")
     assert format_json(result.output) == format_json(
         load_file("examples/yaml_datatypes/output.json")
     )
Beispiel #8
0
 def test_begintag_2(self):
     sql = load_file('begintag_2.sql')
     stmts = sqlparse.parse(sql)
     self.assertEqual(len(stmts), 1)
     self.ndiffAssertEqual(''.join(unicode(q) for q in stmts), sql)
Beispiel #9
0
 def test_dashcomments(self):
     sql = load_file('dashcomment.sql')
     stmts = sqlparse.parse(sql)
     self.assertEqual(len(stmts), 3)
     self.ndiffAssertEqual(''.join(unicode(q) for q in stmts), sql)
Beispiel #10
0
 def test_create_function_psql2(self):
     sql = load_file('function_psql2.sql')
     stmts = sqlparse.parse(sql)
     self.assertEqual(len(stmts), 1)
     self.ndiffAssertEqual(unicode(stmts[0]), sql)
Beispiel #11
0
 def test_begintag_2(self):
     sql = load_file('begintag_2.sql')
     stmts = sqlparse.parse(sql)
     self.assertEqual(len(stmts), 1)
     self.ndiffAssertEqual(''.join(unicode(q) for q in stmts), sql)
Beispiel #12
0
 def test_dashcomments(self):
     sql = load_file('dashcomment.sql')
     stmts = sqlparse.parse(sql)
     self.assertEqual(len(stmts), 3)
     self.ndiffAssertEqual(''.join(unicode(q) for q in stmts), sql)
Beispiel #13
0
 def test_create_function_psql2(self):
     sql = load_file('function_psql2.sql')
     stmts = sqlparse.parse(sql)
     self.assertEqual(len(stmts), 1)
     self.ndiffAssertEqual(unicode(stmts[0]), sql)