def test_value_match(self):
        """
        Tests the _parse method for a 'value' method when a string has a
        match.
        """
        parser = Parser(method='SUBSTRING', regex='Threat:\s*(\w+)\n')
        result = parser._parse(self.string)
        self.assertEqual(result, 'Medium')

        parser = Parser(
            method='SUBSTRING',
            regex='source.?IP.*\s(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')
        result = parser._parse(self.string)
        self.assertEqual(result, '128.101.101.101')
 def test_presence_false(self):
     """
     Tests the _parse method for a 'presence' method when a string has no
     match.
     """
     parser = Parser(method='P/A', regex='Bad Robots')
     result = parser._parse(self.string)
     self.assertFalse(result)
 def test_copy(self):
     """
     Tests the _parse method for a 'value' method when a string has a
     match.
     """
     parser = Parser(method='COPY')
     result = parser._parse('this is an example post')
     self.assertEqual(result, 'this is an example post')
 def test_count_multi_matches(self):
     """
     Tests the _parse method for a 'count' method when a string has
     multiple matches.
     """
     parser = Parser(method='COUNT', regex='Bad Bots')
     result = parser._parse(self.string)
     self.assertEqual(result, 2)
 def test_value_no_match(self):
     """
     Tests the _parse method for a 'value' method when a string has no
     match.
     """
     parser = Parser(method='SUBSTRING', regex='Threats:\s*(\w+)\n')
     result = parser._parse(self.string)
     self.assertEqual(result, None)