Ejemplo n.º 1
0
 def test_table_signature(self):
     """signature() should return a hash of the structure and the data for a table"""
     url = "odbc://tuttle_test_db/test_table"
     res = ODBCResource(url)
     sig = res.signature()
     expected = "7b52009b64fd0a2a49e6d8a939753077792b0554"
     assert sig == expected, sig
Ejemplo n.º 2
0
 def test_partition_signature(self):
     """signature() should return a hash of the structure and the data for a table"""
     url = "odbc://tuttle_test_db/test_partitionned_table_num?col_int=14"
     res = ODBCResource(url)
     sig = res.signature()
     expected = "d22e04365ffe5ba05d7f5ec4f2115fde8d251e3d"
     assert sig == expected, sig
Ejemplo n.º 3
0
 def test_bad_dsn(self):
     """If DSN does not exist, should tell tuttle can't connect !"""
     url = "odbc://unknown_dsn/test_table"
     res = ODBCResource(url)
     try:
         res.exists()
         assert False
     except TuttleError as e:
         assert e.message.find("to check existence of resource") > 0, e.message
Ejemplo n.º 4
0
 def test_odbc_partition_raise_if_table_not_exists(self):
     """exists() for a partition should raise if the table does not exist"""
     url = "odbc://tuttle_test_db/no_table?col1=val1"
     res = ODBCResource(url)
     try:
         res.exists()
         assert False, "Should have raised because the table does not exists"
     except TuttleError as e:
         assert True
Ejemplo n.º 5
0
 def test_remove_partition(self):
     """remove() should remove a table"""
     partition_to_delete = "odbc://tuttle_test_db/test_partitionned_table_num?col_int=14"
     resource_to_delete = ODBCResource(partition_to_delete)
     assert resource_to_delete.exists(), "{} should exist".format(partition_to_delete)
     other_partition = "odbc://tuttle_test_db/test_partitionned_table_num?col_int=42"
     other_resource = ODBCResource(other_partition)
     assert resource_to_delete.exists(), "{} should exist".format(other_partition)
     resource_to_delete.remove()
     assert not resource_to_delete.exists(), "{} should not exist anymore".format(partition_to_delete)
     assert other_resource.exists(), "Other partition {} should still exist".format(other_partition)
Ejemplo n.º 6
0
 def test_parse_too_many_values_in_filter(self):
     """Should raise if url contains several times the same filter"""
     url = "odbc://tuttle_test_db/test_partitionned_table?col1=val1&col1=val2"
     try:
         res = ODBCResource(url)
         assert False, "Should have raised"
     except MalformedUrl as e:
         assert e.message.find("Too many values")
Ejemplo n.º 7
0
 def test_parse_partitionned_url(self):
     """A standard odbc url should provide a valid resource"""
     url = "odbc://tuttle_test_db/test_partitionned_table?col1=val1"
     res = ODBCResource(url)
     assert res._dsn == "tuttle_test_db", res._dsn
     assert res._relation == "test_partitionned_table", res._relation
     assert "col1" in res._filters, res._filters
     assert res._filters["col1"] == "val1", res._filters["col1"]
Ejemplo n.º 8
0
 def test_remove_table(self):
     """remove() should remove a table"""
     url = "odbc://tuttle_test_db/test_table"
     res = ODBCResource(url)
     assert res.exists(), "{} should exist".format(url)
     res.remove()
     assert not res.exists(), "{} should not exist".format(url)
Ejemplo n.º 9
0
 def test_odbc_table_not_exists(self):
     """the table should not exist"""
     url = "odbc://tuttle_test_db/no_table"
     res = ODBCResource(url)
     assert not res.exists(), "{} should exist".format(url)
Ejemplo n.º 10
0
 def test_odbc_table_exists(self):
     """exists() should return True when the table exists"""
     url = "odbc://tuttle_test_db/test_table"
     res = ODBCResource(url)
     assert res.exists(), "{} should exist".format(url)
Ejemplo n.º 11
0
 def test_parse_standard_url(self):
     """A standard odbc url should provide a valid resource"""
     url = "odbc://tuttle_test_db/test_table"
     res = ODBCResource(url)
     assert res._dsn == "tuttle_test_db", res._dsn
     assert res._relation == "test_table", res._table
Ejemplo n.º 12
0
 def test_odbc_table_partition_not_exists(self):
     """exists() should return False if there are no data in the partition"""
     url = "odbc://tuttle_test_db/test_partitionned_table?col1=unknown_value"
     res = ODBCResource(url)
     assert not res.exists(), "{} should not exist".format(url)
Ejemplo n.º 13
0
 def test_odbc_table_partition_does_not_exists_with_int(self):
     """exists() should return True when a partition exists in the table"""
     url = "odbc://tuttle_test_db/test_partitionned_table_num?col_int=13"
     res = ODBCResource(url)
     assert not res.exists(), "{} should not exist".format(url)
Ejemplo n.º 14
0
 def test_odbc_table_partition_exists(self):
     """exists() should return True when a partition exists in the table"""
     url = "odbc://tuttle_test_db/test_partitionned_table?col1=val1"
     res = ODBCResource(url)
     assert res.exists(), "{} should exist".format(url)