示例#1
0
 def test_parse_raw_passes_add_spaces(self):
     fake_parser1 = mock.Mock()
     fake_parser1.should_parse = lambda x: True
     parse_raw([])
     fake_parser1.parse.called_with([None])
     parse_raw([], add_spaces=True)
     fake_parser1.parse.called_with([None, True])
示例#2
0
 def test_is_comment(self):
     from certbot_nginx._internal.parser_obj import _is_comment
     self.assertTrue(_is_comment(parse_raw(['#'])))
     self.assertTrue(
         _is_comment(parse_raw(['#', ' literally anything else'])))
     self.assertFalse(
         _is_comment(parse_raw(['not', 'even', 'a', 'comment'])))
示例#3
0
 def test_is_certbot_comment(self):
     from certbot_nginx._internal.parser_obj import _is_certbot_comment
     self.assertTrue(_is_certbot_comment(
         parse_raw(COMMENT_BLOCK)))
     self.assertFalse(_is_certbot_comment(
         parse_raw(['#', ' not a certbot comment'])))
     self.assertFalse(_is_certbot_comment(
         parse_raw(['#', ' managed by Certbot', ' also not a certbot comment'])))
     self.assertFalse(_is_certbot_comment(
         parse_raw(['not', 'even', 'a', 'comment'])))
示例#4
0
 def test_parse_raw(self):
     fake_parser1 = mock.Mock()
     fake_parser1.should_parse = lambda x: True
     fake_parser2 = mock.Mock()
     fake_parser2.should_parse = lambda x: False
     # First encountered "match" should parse.
     parse_raw([])
     fake_parser1.called_once()
     fake_parser2.not_called()
     fake_parser1.reset_mock()
     # "match" that returns False shouldn't parse.
     parse_raw([])
     fake_parser1.not_called()
     fake_parser2.called_once()