def test_move_non_ticket_config_keys_above_tickets(self): self.assertEqual([ ConfigItem("site", "1.1.1.1"), ConfigItem('site', '2.2.2.2'), ConfigItem('arbitrator', '3.3.3.3'), ConfigItem("ticket", "TA"), ], config_parser.organize_lines([ ("site", "1.1.1.1"), ("ticket", "TA"), ('site', '2.2.2.2'), ('arbitrator', '3.3.3.3'), ]))
def from_exchange_format(exchange_format): return [ ConfigItem( item["key"], item["value"], from_exchange_format(item["details"]), ) for item in exchange_format ]
def test_build_file_content_from_parsed_structure(self): self.assertEqual( "\n".join([ "authfile = /path/to/auth.file", "site = 1.1.1.1", "site = 2.2.2.2", "arbitrator = 3.3.3.3", 'ticket = "TA"', 'ticket = "TB"', " timeout = 10", "", #newline at the end ]), config_parser.build([ ConfigItem("authfile", "/path/to/auth.file"), ConfigItem("site", "1.1.1.1"), ConfigItem("site", "2.2.2.2"), ConfigItem("arbitrator", "3.3.3.3"), ConfigItem("ticket", "TA"), ConfigItem("ticket", "TB", [ConfigItem("timeout", "10")]), ]))
def test_use_ticket_key_as_ticket_detail(self): self.maxDiff = None self.assertEqual( [ ConfigItem("site", "1.1.1.1"), ConfigItem('expire', '300'), ConfigItem('site', '2.2.2.2'), ConfigItem('arbitrator', '3.3.3.3'), ConfigItem("ticket", "TA", [ ConfigItem("timeout", "10"), ConfigItem('--nonexistent', 'value'), ConfigItem("expire", "300"), ]), ConfigItem("ticket", "TB", [ ConfigItem("timeout", "20"), ConfigItem("renewal-freq", "40"), ]), ], config_parser.organize_lines([ ("site", "1.1.1.1"), ("expire", "300"), # out of ticket content is kept global ("ticket", "TA"), ("site", "2.2.2.2"), # move to global ("timeout", "10"), ("--nonexistent", "value"), # no global is kept under ticket ("expire", "300"), ("ticket", "TB"), ('arbitrator', '3.3.3.3'), ("timeout", "20"), ("renewal-freq", "40"), ]) )