コード例 #1
0
ファイル: test_parser.py プロジェクト: buildinspace/peru
 def test_bad_rule_field_throw(self):
     with self.assertRaises(ParserError):
         parse_string(
             dedent("""\
             rule foo:
                 bad_field: junk
             """))
コード例 #2
0
 def test_bad_rule_field_throw(self):
     with self.assertRaises(ParserError):
         parse_string(
             dedent("""\
             rule foo:
                 bad_field: junk
             """))
コード例 #3
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_parse_bad_list_imports_throw(self):
     input = dedent('''\
         imports:
             - a: foo
               b: bar
     ''')
     with self.assertRaises(ParserError):
         parse_string(input)
コード例 #4
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_duplicate_names_throw(self):
     input = dedent("""
         git module {}:
         rule {}:
         """)
     # Should be fine with different names...
     parse_string(input.format("foo", "bar"))
     # But should fail with duplicates.
     with self.assertRaises(ParserError):
         parse_string(input.format("foo", "foo"))
コード例 #5
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_non_string_module_field_name(self):
     input = dedent('''\
         git module foo:
             12345: bar
         ''')
     try:
         parse_string(input)
     except ParserError as e:
         assert '12345' in e.message
     else:
         assert False, 'expected ParserError'
コード例 #6
0
 def test_non_string_module_field_value(self):
     input = dedent('''\
         git module foo:
             bar: 4567
         ''')
     try:
         parse_string(input)
     except ParserError as e:
         assert '4567' in e.message
     else:
         assert False, 'expected ParserError'
コード例 #7
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_build_field_deprecated_message(self):
     input = dedent('''\
         rule foo:
             build: shell command
         ''')
     try:
         parse_string(input)
     except ParserError as e:
         assert 'The "build" field is no longer supported.' in e.message
     else:
         assert False, 'expected ParserError'
コード例 #8
0
 def test_build_field_deprecated_message(self):
     input = dedent('''\
         rule foo:
             build: shell command
         ''')
     try:
         parse_string(input)
     except ParserError as e:
         assert 'The "build" field is no longer supported.' in e.message
     else:
         assert False, 'expected ParserError'
コード例 #9
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_non_string_module_field_value(self):
     input = dedent('''\
         git module foo:
             bar: 4567
         ''')
     try:
         parse_string(input)
     except ParserError as e:
         assert '4567' in e.message
     else:
         assert False, 'expected ParserError'
コード例 #10
0
 def test_non_string_module_field_name(self):
     input = dedent('''\
         git module foo:
             12345: bar
         ''')
     try:
         parse_string(input)
     except ParserError as e:
         assert '12345' in e.message
     else:
         assert False, 'expected ParserError'
コード例 #11
0
ファイル: test_parser.py プロジェクト: emgee/peru
 def test_non_string_module_field_name(self):
     input = dedent(
         """\
         git module foo:
             12345: bar
         """
     )
     try:
         parse_string(input)
     except ParserError as e:
         assert "12345" in e.message
     else:
         assert False, "expected ParserError"
コード例 #12
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_forgotten_colon(self):
     # There are many different permutations of this error, and this only
     # tests the one mentioned in
     # https://github.com/keybase/client/issues/242.
     # TODO: A more general data validation library might help the parser do
     # a better job of checking these things. See
     # https://github.com/buildinspace/peru/issues/40.
     input = dedent('''\
         rule test:
             pick bla
         ''')
     with self.assertRaises(ParserError):
         parse_string(input)
コード例 #13
0
 def test_forgotten_colon(self):
     # There are many different permutations of this error, and this only
     # tests the one mentioned in
     # https://github.com/keybase/client/issues/242.
     # TODO: A more general data validation library might help the parser do
     # a better job of checking these things. See
     # https://github.com/buildinspace/peru/issues/40.
     input = dedent('''\
         rule test:
             pick bla
         ''')
     with self.assertRaises(ParserError):
         parse_string(input)
コード例 #14
0
ファイル: test_parser.py プロジェクト: emgee/peru
 def test_non_string_module_field_value(self):
     input = dedent(
         """\
         git module foo:
             bar: 4567
         """
     )
     try:
         parse_string(input)
     except ParserError as e:
         assert "4567" in e.message
     else:
         assert False, "expected ParserError"
コード例 #15
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_parse_empty_imports(self):
     input = dedent('''\
         imports:
         ''')
     result = parse_string(input)
     self.assertDictEqual(result.scope, {})
     self.assertEqual(result.local_module.imports, build_imports({}))
コード例 #16
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_duplicate_names_throw(self):
     # Modules and rules should not conflict.
     ok_input = dedent('''
         rule foo:
         git module foo:
         ''')
     parse_string(ok_input)
     # But duplicate modules should fail. (Duplicate rules are a not
     # currently possible, because their YAML keys would be exact
     # duplicates.)
     bad_input = dedent('''
         git module foo:
         hg module foo:
         ''')
     with self.assertRaises(ParserError):
         parse_string(bad_input)
コード例 #17
0
 def test_duplicate_names_throw(self):
     # Modules and rules should not conflict.
     ok_input = dedent('''
         rule foo:
         git module foo:
         ''')
     parse_string(ok_input)
     # But duplicate modules should fail. (Duplicate rules are a not
     # currently possible, because their YAML keys would be exact
     # duplicates.)
     bad_input = dedent('''
         git module foo:
         hg module foo:
         ''')
     with self.assertRaises(ParserError):
         parse_string(bad_input)
コード例 #18
0
 def test_parse_empty_imports(self):
     input = dedent('''\
         imports:
         ''')
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {})
コード例 #19
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_empty_imports(self):
     input = dedent('''\
         imports:
         ''')
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {})
コード例 #20
0
 def test_parse_toplevel_imports(self):
     input = dedent("""\
         imports:
             foo: bar/
         """)
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {'foo': ('bar/', )})
コード例 #21
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_parse_toplevel_imports(self):
     input = dedent("""\
         imports:
             foo: bar/
         """)
     result = parse_string(input)
     self.assertDictEqual(result.scope, {})
     self.assertEqual(result.local_module.imports, build_imports(
         {'foo': 'bar/'}))
コード例 #22
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_parse_list_imports(self):
     input = dedent('''\
         imports:
             - foo: bar/
         ''')
     result = parse_string(input)
     self.assertDictEqual(result.scope, {})
     self.assertEqual(result.local_module.imports, build_imports(
         {'foo': 'bar/'}))
コード例 #23
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_toplevel_imports(self):
     input = dedent("""\
         imports:
             foo: bar/
         """)
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {'foo': ('bar/',)})
コード例 #24
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_multimap_imports(self):
     input = dedent('''\
         imports:
             foo:
               - bar/
         ''')
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {'foo': ('bar/',)})
コード例 #25
0
 def test_parse_multimap_imports(self):
     input = dedent('''\
         imports:
             foo:
               - bar/
         ''')
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {'foo': ('bar/', )})
コード例 #26
0
 def test_parse_rule(self):
     input = dedent("""\
         rule foo:
             export: out/
         """)
     scope, imports = parse_string(input)
     self.assertIn("foo", scope.rules)
     rule = scope.rules["foo"]
     self.assertIsInstance(rule, Rule)
     self.assertEqual(rule.name, "foo")
     self.assertEqual(rule.export, "out/")
コード例 #27
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_module_default_rule(self):
     input = dedent("""\
         git module bar:
             export: bar
         """)
     scope, imports = parse_string(input)
     self.assertIn("bar", scope.modules)
     module = scope.modules["bar"]
     self.assertIsInstance(module, Module)
     self.assertIsInstance(module.default_rule, Rule)
     self.assertEqual(module.default_rule.export, "bar")
コード例 #28
0
 def test_parse_module_default_rule(self):
     input = dedent("""\
         git module bar:
             export: bar
         """)
     scope, imports = parse_string(input)
     self.assertIn("bar", scope.modules)
     module = scope.modules["bar"]
     self.assertIsInstance(module, Module)
     self.assertIsInstance(module.default_rule, Rule)
     self.assertEqual(module.default_rule.export, "bar")
コード例 #29
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_rule(self):
     input = dedent("""\
         rule foo:
             export: out/
         """)
     scope, imports = parse_string(input)
     self.assertIn("foo", scope.rules)
     rule = scope.rules["foo"]
     self.assertIsInstance(rule, Rule)
     self.assertEqual(rule.name, "foo")
     self.assertEqual(rule.export, "out/")
コード例 #30
0
ファイル: test_parser.py プロジェクト: emgee/peru
 def test_parse_multimap_imports(self):
     input = dedent(
         """\
         imports:
             foo:
               - bar/
         """
     )
     scope, imports = parse_string(input)
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {"foo": ("bar/",)})
コード例 #31
0
    def test_name_prefix(self):
        input = dedent('''\
            git module foo:
                url: fun stuff

            rule bar:
                export: more stuff
            ''')
        scope, imports = parse_string(input, name_prefix='x')
        # Lookup keys should be unaffected, but the names that modules and
        # rules give for themselves should have the prefix.
        assert scope.modules['foo'].name == 'xfoo'
        assert scope.rules['bar'].name == 'xbar'
コード例 #32
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_parse_module_default_rule(self):
     input = dedent("""\
         git module bar:
             build: foo
             export: bar
         """)
     result = parse_string(input)
     self.assertIn("bar", result.scope)
     module = result.scope["bar"]
     self.assertIsInstance(module, RemoteModule)
     self.assertIsInstance(module.default_rule, Rule)
     self.assertEqual(module.default_rule.build_command, "foo")
     self.assertEqual(module.default_rule.export, "bar")
コード例 #33
0
ファイル: test_parser.py プロジェクト: Arvindhm/peru
 def test_parse_rule(self):
     input = dedent("""\
         rule foo:
             build: echo hi
             export: out/
         """)
     result = parse_string(input)
     self.assertIn("foo", result.scope)
     rule = result.scope["foo"]
     self.assertIsInstance(rule, Rule)
     self.assertEqual(rule.name, "foo")
     self.assertEqual(rule.build_command, "echo hi")
     self.assertEqual(rule.export, "out/")
コード例 #34
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
    def test_name_prefix(self):
        input = dedent('''\
            git module foo:
                url: fun stuff

            rule bar:
                export: more stuff
            ''')
        scope, imports = parse_string(input, name_prefix='x')
        # Lookup keys should be unaffected, but the names that modules and
        # rules give for themselves should have the prefix.
        assert scope.modules['foo'].name == 'xfoo'
        assert scope.rules['bar'].name == 'xbar'
コード例 #35
0
ファイル: test_parser.py プロジェクト: emgee/peru
    def test_name_prefix(self):
        input = dedent(
            """\
            git module foo:
                url: fun stuff

            rule bar:
                export: more stuff
            """
        )
        scope, imports = parse_string(input, name_prefix="x")
        # Lookup keys should be unaffected, but the names that modules and
        # rules give for themselves should have the prefix.
        assert scope.modules["foo"].name == "xfoo"
        assert scope.rules["bar"].name == "xbar"
コード例 #36
0
 def test_non_string_module_field_value(self):
     input = dedent('''\
         git module foo:
             bar: 123
             # These booleans should turn into "true" and "false".
             baz: yes
             bing: no
         ''')
     scope, imports = parse_string(input)
     foo = scope.modules['foo']
     self.assertDictEqual(foo.plugin_fields, {
         "bar": "123",
         "baz": "true",
         "bing": "false",
     })
コード例 #37
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_non_string_module_field_value(self):
     input = dedent('''\
         git module foo:
             bar: 123
             # These booleans should turn into "true" and "false".
             baz: yes
             bing: no
         ''')
     scope, imports = parse_string(input)
     foo = scope.modules['foo']
     self.assertDictEqual(foo.plugin_fields, {
         "bar": "123",
         "baz": "true",
         "bing": "false",
     })
コード例 #38
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_module(self):
     input = dedent("""\
         sometype module foo:
             url: http://www.example.com/
             rev: abcdefg
         """)
     scope, imports = parse_string(input)
     self.assertIn("foo", scope.modules)
     module = scope.modules["foo"]
     self.assertIsInstance(module, Module)
     self.assertEqual(module.name, "foo")
     self.assertEqual(module.type, "sometype")
     self.assertDictEqual(module.plugin_fields,
                          {"url": "http://www.example.com/",
                           "rev": "abcdefg"})
コード例 #39
0
 def test_parse_module(self):
     input = dedent("""\
         sometype module foo:
             url: http://www.example.com/
             rev: abcdefg
         """)
     scope, imports = parse_string(input)
     self.assertIn("foo", scope.modules)
     module = scope.modules["foo"]
     self.assertIsInstance(module, Module)
     self.assertEqual(module.name, "foo")
     self.assertEqual(module.type, "sometype")
     self.assertDictEqual(module.plugin_fields, {
         "url": "http://www.example.com/",
         "rev": "abcdefg"
     })
コード例 #40
0
ファイル: test_parser.py プロジェクト: mgartner/peru
 def test_parse_module(self):
     input = dedent("""\
         sometype module foo:
             url: http://www.example.com/
             rev: abcdefg
             imports:
                 wham: bam/
                 thank: you/maam
         """)
     result = parse_string(input)
     self.assertIn("foo", result.scope)
     module = result.scope["foo"]
     self.assertIsInstance(module, RemoteModule)
     self.assertEqual(module.name, "foo")
     self.assertEqual(module.type, "sometype")
     self.assertEqual(module.imports, build_imports(
         {'wham': 'bam/', 'thank': 'you/maam'}))
     self.assertDictEqual(module.plugin_fields,
                          {"url": "http://www.example.com/",
                           "rev": "abcdefg"})
コード例 #41
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_bad_toplevel_field_throw(self):
     with self.assertRaises(ParserError):
         parse_string("foo: bar")
コード例 #42
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_wrong_type_imports_throw(self):
     with self.assertRaises(ParserError):
         parse_string('imports: 5')
コード例 #43
0
 def test_parse_empty_file(self):
     scope, imports = parse_string('')
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {})
コード例 #44
0
 def test_bad_rule_name_throw(self):
     with self.assertRaises(ParserError):
         parse_string("rule foo bar:")
コード例 #45
0
 def test_bad_module_name_throw(self):
     with self.assertRaises(ParserError):
         parse_string("git module abc def:")
     with self.assertRaises(ParserError):
         parse_string("git module:")
コード例 #46
0
 def test_parse_wrong_type_imports_throw(self):
     with self.assertRaises(ParserError):
         parse_string('imports: 5')
コード例 #47
0
 def test_bad_toplevel_field_throw(self):
     with self.assertRaises(ParserError):
         parse_string("foo: bar")
コード例 #48
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_bad_module_name_throw(self):
     with self.assertRaises(ParserError):
         parse_string("git module abc def:")
     with self.assertRaises(ParserError):
         parse_string("git module:")
コード例 #49
0
ファイル: test_parser.py プロジェクト: oconnor663/peru
 def test_parse_empty_file(self):
     scope, imports = parse_string('')
     self.assertDictEqual(scope.modules, {})
     self.assertDictEqual(scope.rules, {})
     self.assertEqual(imports, {})