Exemplo n.º 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.")
Exemplo n.º 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)
Exemplo n.º 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.")
Exemplo n.º 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')
Exemplo n.º 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.")
Exemplo n.º 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.")
Exemplo n.º 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()
Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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.")
Exemplo n.º 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)
Exemplo n.º 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.")
Exemplo n.º 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")
Exemplo n.º 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.")
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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.")
Exemplo n.º 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("")
Exemplo n.º 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.")