Esempio n. 1
0
def config_ticket_remove(
    env: LibraryEnvironment, ticket_name, instance_name=None,
):
    """
    remove a ticket from booth configuration

    env
    string ticket_name -- the name of the ticket to be removed
    string instance_name -- booth instance name
    """
    report_processor = env.report_processor
    booth_env = env.get_booth_env(instance_name)
    try:
        booth_conf = booth_env.config.read_to_facade()
        report_processor.report_list(
            config_validators.remove_ticket(booth_conf, ticket_name)
        )
        if report_processor.has_errors:
            raise LibraryError()
        booth_conf.remove_ticket(ticket_name)
        booth_env.config.write_facade(booth_conf, can_overwrite=True)
    except RawFileError as e:
        report_processor.report(raw_file_error_report(e))
    except ParserErrorException as e:
        report_processor.report_list(
            booth_env.config.parser_exception_to_report_list(e)
        )
    if report_processor.has_errors:
        raise LibraryError()
 def test_report_not_a_ticket(self):
     assert_report_item_list_equal(
         config_validators.remove_ticket(self.conf, "site1"),
         [
             fixture.error(
                 report_codes.BOOTH_TICKET_DOES_NOT_EXIST,
                 ticket_name="site1",
             )
         ]
     )
 def test_no_reports_on_existing_ticket(self):
     assert_report_item_list_equal(
         config_validators.remove_ticket(self.conf, "ticketA"),
         []
     )