Exemplo n.º 1
0
 def test_complex_filter(self):
     logs = [
         {
             "timestamp": "2020-05-11T13:42:50",
             "status": "error",
             "countryISO2": "BG"
         },
         {
             "timestamp": "2020-05-11T13:43:20",
             "status": "success",
             "countryISO2": "UK"
         },
         {
             "timestamp": "2020-05-11T13:44:30",
             "status": "success",
             "countryISO2": "NZ"
         },
     ]
     res = solution.complex_filter(logs, {
         "status": "success",
         "countryISO2": "NZ"
     })
     self.assertEqual([logs[2]], res)
Exemplo n.º 2
0
 def test_complex_filter_returns_all_logs_if_no_params_are_given(self):
     res = solution.complex_filter(self.logs, {})
     self.assertEqual(self.logs, res)
Exemplo n.º 3
0
 def test_complex_filter_returns_empty_list_if_no_params_match(self):
     res = solution.complex_filter(self.logs, {
         "status": "error",
         "countryISO2": "UK"
     })
     self.assertEqual([], res)
Exemplo n.º 4
0
 def test_complex_filter_with_multiple_params(self):
     res = solution.complex_filter(self.logs, {
         "status": "success",
         "countryISO2": "NZ"
     })
     self.assertEqual([self.logs[2]], res)
Exemplo n.º 5
0
 def test_complex_filter_with_one_param(self):
     res = solution.complex_filter(self.logs, {"status": "error"})
     self.assertEqual([self.logs[0]], res)
Exemplo n.º 6
0
 def test_complex_filter_with_empty_filter(self):
     res = solution.complex_filter(self.logs, {})
     self.assertEqual(self.logs, res)
Exemplo n.º 7
0
 def test_complex_filter_with_filter_keys_not_part_of_log_keys(self):
     res = solution.complex_filter(self.logs, {"test": 123})
     self.assertEqual([], res)