def load(self): """Load Classic CS Unplugged pages. Raise: MissingRequiredFieldError: when no object can be found with the matching attribute. """ classic_pages = self.load_yaml_file(self.structure_file_path) for (slug, page_data) in classic_pages.items(): try: name = page_data["name"] except (TypeError, KeyError): raise MissingRequiredFieldError( self.structure_file_path, [ "name", ], "Classic CS Unplugged page" ) redirect_url = urljoin("https://classic.csunplugged.org/", slug) classic_page = ClassicPage( slug=slug, name=name, redirect=redirect_url, ) classic_page.save() self.log("Added Classic CS Unplugged page: {}".format(name)) self.log("All Classic CS Unplugged pages loaded!\n")
def test_rebuild_index_command_classic_page_model(self): page = ClassicPage( slug="page", name="Page", redirect="http://www.example.com", ) page.save() management.call_command("rebuild_index", "--noinput")