Exemplo n.º 1
0
 def test_default(self):
     suite = Pa11yCrawler(
         'pa11ycrawler',
         course_key="course-v1:edX+Test101+course",
     )
     ignore = ("pa11y_ignore_rules_url="
               "https://raw.githubusercontent.com/edx/"
               "pa11ycrawler-ignore/master/ignore.yaml")
     expected_cmd = [
         "scrapy",
         "crawl",
         "edx",
         "-a",
         "port=8003",
         "-a",
         "course_key=course-v1:edX+Test101+course",
         "-a",
         ignore,
         "-a",
         "data_dir=/edx/app/edxapp/edx-platform/reports/pa11ycrawler/data",
     ]
     actual_cmd = suite.cmd
     # verify that the final section of this command is for specifying the
     # data directory
     self.assertEqual(actual_cmd[-2], "-a")
     self.assertTrue(actual_cmd[-1].startswith("data_dir="))
     # chop off the `data_dir` argument when comparing,
     # since it is highly dependent on who is running this paver command,
     # and where it's being run (devstack, jenkins, etc)
     self.assertEqual(actual_cmd[0:-2], expected_cmd[0:-2])
Exemplo n.º 2
0
 def test_generate_html_reports(self):
     suite = Pa11yCrawler('')
     suite.generate_html_reports()
     self._mock_sh.assert_has_calls([
         call('pa11ycrawler json-to-html --pa11ycrawler-reports-dir={}'.
              format(suite.pa11y_report_dir)),
     ])
Exemplo n.º 3
0
 def test_get_test_course(self):
     suite = Pa11yCrawler('')
     suite.get_test_course()
     self._mock_sh.assert_has_calls([
         call('wget {targz} -O {dir}demo_course.tar.gz'.format(
             targz=suite.tar_gz_file, dir=suite.imports_dir)),
         call('tar zxf {dir}demo_course.tar.gz -C {dir}'.format(
             dir=suite.imports_dir)),
     ])
Exemplo n.º 4
0
 def test_generate_html_reports(self):
     suite = Pa11yCrawler('pa11ycrawler')
     suite.generate_html_reports()
     self._mock_sh.assert_has_calls([
         call([
             'pa11ycrawler-html',
             '--data-dir',
             os.path.join(suite.report_dir, "data"),
             '--output-dir',
             os.path.join(suite.report_dir, "html"),
         ])
     ])
Exemplo n.º 5
0
    def test_scrapy_cfg_exists(self, mocked_path_func):
        # setup
        mock_path = Mock()
        mock_path.expand.return_value = mock_path
        mock_path.isfile.return_value = True
        mocked_path_func.return_value = mock_path

        # test
        Pa11yCrawler('pa11ycrawler')

        # check
        mocked_path_func.assert_called_with("~/.config/scrapy.cfg")
        self.assertTrue(mock_path.isfile.called)
        self.assertFalse(mock_path.write_text.called)
Exemplo n.º 6
0
    def test_scrapy_cfg_not_exists(self, mocked_path_func):
        # setup
        mock_path = Mock()
        mock_path.expand.return_value = mock_path
        mock_path.isfile.return_value = False
        mocked_path_func.return_value = mock_path

        # test
        Pa11yCrawler('pa11ycrawler')

        # check
        mocked_path_func.assert_called_with("~/.config/scrapy.cfg")
        self.assertTrue(mock_path.isfile.called)
        self.assertTrue(mock_path.parent.makedirs_p.called)
        content = dedent("""
            [settings]
            default = pa11ycrawler.settings

            [deploy]
            project = pa11ycrawler
        """)
        mock_path.write_text.assert_called_with(content)
Exemplo n.º 7
0
 def test_default(self):
     suite = Pa11yCrawler('')
     self.assertEqual(
         suite.cmd,
         self._expected_command(suite.pa11y_report_dir, suite.start_urls))