def test_spec_to_schema_name(spec, expected_name): """ GIVEN spec and expected name WHEN _spec_to_schema_name is called with the spec THEN the expected name is returned """ name = factory._spec_to_schema_name(spec=spec) # pylint: disable=protected-access assert name == expected_name
def test_map_index(spec, expected_spec): """ GIVEN specification and expected specification WHEN _map_index is called with the specification THEN the expected specification is returned which is a valid IndexList. """ returned_spec = factory._map_index(spec=spec) # pylint: disable=protected-access assert returned_spec == expected_spec assert (factory._spec_to_schema_name( # pylint: disable=protected-access spec=returned_spec) == "IndexList")
def test_construct_unique(spec, expected_name, expected_columns): """ GIVEN spec, expected name and columns WHEN _construct_unique is called THEN a unique constraint with the expected name and columns is returned. """ assert (factory._spec_to_schema_name(spec=spec) # pylint: disable=protected-access == "Unique") unique = factory._construct_unique(spec=spec) # pylint: disable=protected-access assert unique.name == expected_name assert (unique._pending_colargs == expected_columns # pylint: disable=protected-access )
def test_construct_index(spec, expected_name, expected_expressions, expected_unique): """ GIVEN spec, expected name, expressions and unique WHEN _construct_index is called THEN a index with the expected name, expressions and unique is returned. """ assert (factory._spec_to_schema_name(spec=spec) # pylint: disable=protected-access == "Index") index = factory._construct_index(spec=spec) # pylint: disable=protected-access assert index.name == expected_name assert index.expressions == expected_expressions assert index.unique == expected_unique