def sample(site_id, sitemap_url, limit=None, samples_filename=None, config_file=None): """Create sample_paths.txt File.""" # Error Cheching if not site_id and not sitemap_url: err = "Either `site_id` or `sitemap_url`are required to run sampling." raise IncorrectParameters(err) config = Config(cfiles=[config_file]) if config_file else Config() # Main function if site_id: samples = get_sample_paths( config, site_id=site_id, limit=limit, filename=samples_filename ) _LOG.info("Top 5 out of {} sampled Paths for {}".format(len(samples), site_id)) _LOG.info(json.dumps(samples[:5], indent=4)) else: samples = get_sample_paths( config, sitemap_url=sitemap_url, limit=limit, filename=samples_filename ) _LOG.info( "Top 5 out of {} sampled Paths for {}".format(len(samples), sitemap_url) ) _LOG.info(json.dumps(samples[:5], indent=4)) return 0
def __init__(self, config=None, sample_paths=None): """Initialize SEOTestingModule Class.""" super(SEOTestingModule, self).__init__(config, sample_paths) self.modulename = "example_module" self.config = config or Config(module=self.modulename) self.exclusions = self.config.example_module.ignore
def __init__(self, config=None, sample_paths=None): """Initialize SEOTestingModule Class.""" super(SEOTestingModule, self).__init__(config, sample_paths) self.modulename = "contentking" self.config = config or Config(module=self.modulename) self.exclusions = self.config.contentking.ignore self.time_zone = pytz.timezone(self.config.contentking.TIMEZONE)
def __init__(self, config=None): """Initialize SEOTesting Class""" self.config = config or Config() self.messages = [] self.module_config = ModuleConfig(self.config) self.sample_paths = None self.modules = None self.summary = None self.passing = True
def __init__(self, config=None): self.browser = None self.page = None self.coverage = None self.client = None self.config = config or Config(module="headless") self.network = self.config.headless.NETWORK_PRESET or "Regular3G" self.user_agent = self.config.headless.USER_AGENT or USER_AGENT asyncio.set_event_loop(asyncio.new_event_loop()) asyncio.get_event_loop().run_until_complete(self.build_browser())
def execute(self, sample_paths=None): """Execute modules against argument, sample_paths.""" self.summary = {"started": str(datetime.now())} # Get Sample Paths self.sample_paths = sample_paths or self.sample_paths self.summary.update({"samples": len(self.sample_paths)}) # get Modules self.modules = self.module_config.module_names self.summary.update({"modules": ",".join(self.modules)}) print() print("SEODeploy: Brought to you by LOCOMOTIVE®") print("Loaded...") print() for active_module in self.module_config.active_modules: module_config = Config(module=active_module, cfiles=self.config.cfiles[:1]) module = self.module_config.active_modules[active_module].SEOTestingModule( config=module_config ) print("Running Module: {}".format(module.modulename)) _LOG.info("Running Module: {}".format(module.modulename)) messages, errors = module.run(sample_paths=self.sample_paths) print("Number of Messages: {}".format(len(messages))) _LOG.info("Number of Messages: {}".format(len(messages))) passing = len(messages) == 0 self._update_messages(messages) self._update_passing(passing) self.summary.update({"{} passing: ".format(module.modulename): passing}) self.summary.update({"{} errors: ".format(module.modulename): len(errors)}) if errors: _LOG.error("Run Errors:" + json.dumps(errors, indent=2)) print() self.get_messages().to_csv("output.csv", index=False) self.print_summary() return self.passing
def execute(samples_filename=None, config_file=None): """Difftest Staging and Production URLs.""" # Maybe set config file. config = Config(cfiles=[config_file]) if config_file else Config() # Set samples_filename. samples_filename = samples_filename or config.SAMPLES_FILENAME # Error Cheching if not samples_filename: raise IncorrectParameters( "You must provide either `samples_filename` " + "or set `samples_filename` in `seodeploy_config.yaml`." ) sample_paths = get_sample_paths(config, filename=samples_filename) # Main function seotesting = SEOTesting(config=config) passing = seotesting.execute(sample_paths=sample_paths) return 1 if passing else 0
def __init__(self, config=None, sample_paths=None): """Initialize ModuleBase Class. Parameters ---------- config: Config class Config class for module. sample_paths: list List of paths. """ self.messages = None self.passing = None self.modulename = None self.exclusions = None self.sample_paths = sample_paths self.config = config or Config()
def test_helpers_process_page_data(): config = Config(module="headless") data1 = [ {"path": "/path1/", "page_data": ["data1"], "error": None}, {"path": "/path2/", "page_data": ["data2"], "error": None}, {"path": "/path3/", "page_data": None, "error": "error3"}, ] data2 = [ {"path": "/path1/", "page_data": ["data1"], "error": None}, {"path": "/path2/", "page_data": ["data2"], "error": None}, {"path": "/path3/", "page_data": None, "error": "error3"}, ] paths = ["/path1/", "/path2/", "/path3/"] assert helpers.process_page_data(paths, data1, data2, config.headless) == { "/path1/": {"prod": ["data1"], "stage": ["data1"], "error": None}, "/path2/": {"prod": ["data2"], "stage": ["data2"], "error": None}, "/path3/": {"prod": None, "stage": None, "error": "error3"}, }
def __init__(self, config=None, mdirs=None): """Initialize ModuleConfig Class. Parameters ---------- config: Config class Config class for module. mdirs: list List of module directory locations. """ self.config = config or Config() self.mdirs = mdirs + ["modules"] if mdirs else ["modules"] self.data = self._get_module_data() self.module_paths = self._get_module_paths(self.data) self.module_names = self._get_module_names(self.data) self.active_modules = {} self._build_modules()
# included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import logging from logging import DEBUG, INFO, ERROR, Formatter, getLogger # noqa: unused-import from seodeploy.lib.config import Config CONFIG = Config() # file output FILE_HANDLER = logging.FileHandler(filename=CONFIG.LOG_FILE or "seotesting.error.log") FILE_HANDLER.setFormatter( Formatter("%(asctime)s [%(levelname)s]" " %(name)s,%(lineno)s %(message)s") ) FILE_HANDLER.setLevel(DEBUG) # console output CONSOLE_HANDLER = logging.StreamHandler() CONSOLE_HANDLER.setLevel(ERROR) CONSOLE_HANDLER.setFormatter(Formatter("%(message)s"))
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """Headless Module for SEODeploy.""" import os from seodeploy.lib.modules import ModuleBase from seodeploy.lib.config import Config CONFIG = Config(module="headless") os.environ["PYPPETEER_CHROMIUM_REVISION"] = str( CONFIG.headless.PYPPETEER_CHROMIUM_REVISION ) from seodeploy.modules.headless.functions import run_render # noqa class SEOTestingModule(ModuleBase): """SEODeploy Module: Headless Module.""" def __init__(self, config=None, sample_paths=None): """Initialize SEOTestingModule Class."""