Example #1
0
 def test_validate_api(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         rds.validate_api("api", "https://some.net/api/call")
         self.assertTrue(
             True, "Should not throw an exception on an API in the URL.")
Example #2
0
 def test_validate_int_float(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         with self.assertRaises(ValidationException,
                                msg="Should throw exception on a variable that is not an integer."):
             rds.validate_int("Variable", "100.1", 100, 200)
Example #3
0
 def test_validate_json(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         rds.validate_json("Json Var", '{"json":"value"}')
         mock_conn.assert_called_once()
         self.assertTrue(True,
                         "Should not throw an exception on valid JSON.")
Example #4
0
 def test_validate_json_invalid(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         with self.assertRaises(
                 ValidationException,
                 msg="Should throw an exception on invalid JSON."):
             rds.validate_json("Json Var", 'not json')
Example #5
0
 def test_validate_contains_text(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         rds.validate_contains("Variable", "Contains")
         mock_conn.assert_called_once()
         self.assertTrue(
             True,
             "Should not throw exception on a variable that contains text.")
Example #6
0
 def test_validate_int(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         rds.validate_int("Variable", "100", 100, 200)
         mock_conn.assert_called_once()
         self.assertTrue(
             True,
             "Should not throw exception on a variable that is an integer.")
Example #7
0
 def test_validate_contains_none(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         with self.assertRaises(
                 ValidationException,
                 msg="Should throw exception on a variable that is None."):
             rds.validate_contains("Variable", None)
             mock_conn.assert_called_once()
Example #8
0
 def test_validate_int_outside_range(self, mock_conn):
     rds = RDS()
     mock_conn.assert_called_once()
     with self.assertRaises(
             ValidationException,
             msg=
             "Should throw exception on a variable that is not an integer in range."
     ):
         rds.validate_int("Variable", "99", 100, 200)
Example #9
0
 def test_validate_api_missing(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         with self.assertRaises(
                 ValidationException,
                 msg=
                 "Should throw an exception on an API missing in the URL."):
             rds.validate_api("api", "https://some.net/other/call")
Example #10
0
 def test_db_connect(self, mock_connection):
     mock_connection.return_value.cursor.return_value = mock.Mock()
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         RDS()
         mock_connection.assert_called_with(host='some-host',
                                            database='some-database',
                                            user='******',
                                            password='******',
                                            connect_timeout=65)
Example #11
0
 def test_validate_uuid_invalid(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         with self.assertRaises(ValidationException, msg="Should throw an exception on invalid UUID."):
             rds.validate_uuid("This is not a uuid")
Example #12
0
 def test_validate_int(self):
     rds = RDS()
     rds.validate_int("Variable", "100", 100, 200)
     self.assertTrue(True, "Should not throw exception on a variable that is an integer.")
Example #13
0
 def test_validate_int_float(self):
     rds = RDS()
     with self.assertRaises(ValidationException, msg="Should throw exception on a variable that is not an integer."):
         rds.validate_int("Variable", "100.1", 100, 200)
Example #14
0
 def test_validate_api(self):
     rds = RDS()
     rds.validate_api("api", "https://some.net/api/call")
     self.assertTrue(True, "Should not throw an exception on an API in the URL.")
Example #15
0
 def test_validate_api_missing(self):
     rds = RDS()
     with self.assertRaises(ValidationException, msg="Should throw an exception on an API missing in the URL."):
         rds.validate_api("api", "https://some.net/other/call")
Example #16
0
 def test_validate_json(self):
     rds = RDS()
     rds.validate_json("Json Var", '{"json":"value"}')
     self.assertTrue(True, "Should not throw an exception on valid JSON.")
Example #17
0
 def test_validate_contains_none(self):
     rds = RDS()
     with self.assertRaises(ValidationException, msg="Should throw exception on a variable that is None."):
         rds.validate_contains("Variable", None)
Example #18
0
 def test_validate_json_invalid(self):
     rds = RDS()
     with self.assertRaises(ValidationException, msg="Should throw an exception on invalid JSON."):
         rds.validate_json("Json Var", 'not json')
Example #19
0
 def test_validate_uuid(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         rds.validate_uuid("0074973a-c377-472f-9f3c-f093fdc18836")
         self.assertTrue(True, "Should not throw an exception on a valid UUID.")
Example #20
0
 def test_validate_uuid_missing(self, mock_conn):
     with mock.patch.dict('src.etl.rds.CONFIG', self.config):
         rds = RDS()
         mock_conn.assert_called_once()
         with self.assertRaises(ValidationException, msg="Should throw an exception on a uuid missing in the URL."):
             rds.validate_uuid("")
Example #21
0
 def test_validate_contains_text(self):
     rds = RDS()
     rds.validate_contains("Variable", "Contains")
     self.assertTrue(True, "Should not throw exception on a variable that contains text.")