예제 #1
0
    def test_all_three(self):
        """test parsing all three"""
        texts = [{"days": 60, "aggregate": "time", "filter": Interaction.NEGATIVE},
                 {"days": 7, "aggregate": "time", "filter": Interaction.POSITIVE},
                 {"days": 45, "aggregate": "person", "filter": Interaction.POSITIVE}]

        for text in texts:
            values = [str(v) for v in text.values() if v is not None]
            parse_str = " ".join(values)
            self.assertEqual(parse_log_request_text(parse_str),
                             (text["days"], text["aggregate"], text["filter"]))
예제 #2
0
    def test_two(self):
        """test combinations of two args to parse"""
        texts = [{"days": 60, "aggregate": None, "filter": Interaction.NEGATIVE},
                 {"days": None, "aggregate": "time", "filter": Interaction.POSITIVE},
                 {"days": 45, "aggregate": "person", "filter": None}]

        for text in texts:
            values = [str(v) for v in text.values() if v is not None]
            parse_str = " ".join(values)
            self.assertEqual(parse_log_request_text(parse_str),
                             (text["days"] or DEFAULT_LOG_DAYS, text["aggregate"],
                              text["filter"]))
예제 #3
0
 def test_filters(self):
     """test for filter recognition"""
     texts = [Interaction.POSITIVE, Interaction.NEGATIVE]
     for text in texts:
         self.assertEqual(parse_log_request_text(text),
                          (DEFAULT_LOG_DAYS, None, text))
예제 #4
0
 def test_aggregates(self):
     """test for aggregate recognition"""
     texts = ["person", "time"]
     for text in texts:
         self.assertEqual(parse_log_request_text(text),
                          (DEFAULT_LOG_DAYS, text, None))
예제 #5
0
 def test_days(self):
     """test for days recognition"""
     text = "60"
     self.assertEqual(parse_log_request_text(text), (60, None, None))
예제 #6
0
 def test_no_addl_text(self):
     """test defaults with no command text"""
     text = ""
     self.assertEqual(parse_log_request_text(text), (DEFAULT_LOG_DAYS, None, None))