def test_check_prerequisites(self):
        with requests_mock.Mocker() as m:
            m.add_matcher(custom_matcher)
            self.assertTrue(URLBear.check_prerequisites())

            m.head(URLBear.check_connection_url,
                   exc=requests.exceptions.RequestException)

            self.assertTrue(URLBear.check_prerequisites() ==
                            'You are not connected to the internet.')
    def test_check_prerequisites(self):
        with requests_mock.Mocker() as m:
            m.add_matcher(custom_matcher)
            self.assertTrue(URLBear.check_prerequisites())

            m.head(URLBear.check_connection_url,
                   exc=requests.exceptions.RequestException)

            self.assertTrue(URLBear.check_prerequisites() ==
                            'You are not connected to the internet.')
    def assertSeverity(self, file, severity, settings={}):
        """
        Test the warnings in each line of the file to match the
        given severity.
        :param file: The ``file`` to be checked.
        :param severity: The severity level of the warnings in each
                         line of the file.
        """
        severity_tag = RESULT_SEVERITY.reverse[severity]
        with requests_mock.Mocker() as m:
            m.add_matcher(custom_matcher)
            dep_bear = URLBear(self.section, Queue())
            deps_results = dict(
                URLBear=list(dep_bear.run('testfile', file, **settings)))

            outputs = list(
                self.uut.run('testfile', file, deps_results, **settings))
            for out in outputs:
                out_dict = out.to_string_dict()
                self.assertEqual(severity_tag, out_dict['severity'])
    def assertSeverity(self, file, severity, settings={}):
        """
        Test the warnings in each line of the file to match the
        given severity.
        :param file: The ``file`` to be checked.
        :param severity: The severity level of the warnings in each
                         line of the file.
        """
        severity_tag = RESULT_SEVERITY.reverse[severity]
        with requests_mock.Mocker() as m:
            m.add_matcher(custom_matcher)
            dep_bear = URLBear(self.section, Queue())
            deps_results = dict(URLBear=list(dep_bear.run('testfile',
                                                          file,
                                                          **settings)))

            outputs = list(self.uut.run('testfile', file, deps_results,
                                        **settings))
            for out in outputs:
                out_dict = out.to_string_dict()
                self.assertEqual(severity_tag, out_dict['severity'])
 def setUp(self):
     self.section = Section('')
     self.uut = URLBear(self.section, Queue())
 def setUp(self):
     self.ib_check_prerequisites = URLBear.check_prerequisites
     self.section = Section('')
     URLBear.check_prerequisites = lambda *args: True
     self.uut = URLBear(self.section, Queue())
 def test_check_prerequisites(self):
     with requests_mock.Mocker() as m:
         m.add_matcher(custom_matcher)
         self.assertTrue(URLBear.check_prerequisites())