def test_schema_tool_supported_database(): if get_current_db_type() != 'mysql': with pytest.raises(UnsupportedDBError): SchemaTool() return assert SchemaTool()
def test_schema_tool_supported_database(): if get_current_db_type() != 'mysql': with pytest.raises(UnsupportedDBError): SchemaTool() return assert SchemaTool()
def test_table_schema_supported_databases(capfd): if get_current_db_type() != 'mysql': with pytest.raises(CommandError): call_command('schema', 'table', 'pootle_store_store') return call_command('schema', 'table', 'pootle_store_store') out, err = capfd.readouterr() assert '' == err
def test_schema_tables(capfd): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") call_command('schema', '--tables') out, err = capfd.readouterr() schema_tool = SchemaTool() result = SchemaDump() result.load(json.loads(out)) assert schema_tool.get_tables() == result.tables
def test_schema_app(capfd): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") call_command('schema', 'app', 'pootle_store') out, err = capfd.readouterr() result = SchemaDump() result.load(json.loads(out)) schema_tool = SchemaTool('pootle_store') for table_name in schema_tool.get_tables(): table_result = result.apps['pootle_store'].tables[table_name] _test_table_result(schema_tool, table_result, table_name)
def test_schema_table(capfd): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") call_command('schema', 'table', 'pootle_store_store') out, err = capfd.readouterr() schema_tool = SchemaTool() result = SchemaDump() result.load(json.loads(out)) app_label = schema_tool.get_app_by_table('pootle_store_store') table_result = result.apps[app_label].tables['pootle_store_store'] _test_table_result(schema_tool, table_result, 'pootle_store_store')
def test_schema_tool(): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") schema_tool = SchemaTool() defaults = schema_tool.get_defaults() assert set(defaults.keys()) == TEST_MYSQL_SCHEMA_PARAM_NAMES['defaults'] for app_label in schema_tool.app_configs: for table in schema_tool.get_app_tables(app_label): row = schema_tool.get_table_fields(table).values()[0] assert (set([x.lower() for x in row.keys()]).issubset( TEST_MYSQL_SCHEMA_PARAM_NAMES['tables']['fields'])) row = schema_tool.get_table_indices(table).values()[0] assert (set([x.lower() for x in row.keys()]).issubset( TEST_MYSQL_SCHEMA_PARAM_NAMES['tables']['indices'])) row = schema_tool.get_table_constraints(table).values()[0] assert (set([x.lower() for x in row.keys()]).issubset( TEST_MYSQL_SCHEMA_PARAM_NAMES['tables']['constraints']))
def test_schema_dump(test_fs): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") schema_tool = SchemaTool() expected_result = SchemaDump() with test_fs.open(['data', 'schema.json']) as f: expected_result.load(data=json.loads(f.read())) assert expected_result.defaults == schema_tool.get_defaults() for app_label in schema_tool.app_configs: expected_app_result = expected_result.get_app(app_label) for table_name in schema_tool.get_app_tables(app_label): expected_table_result = expected_app_result.get_table(table_name) assert (schema_tool.get_table_fields(table_name) == expected_table_result.fields) assert (schema_tool.get_table_indices(table_name) == expected_table_result.indices) assert (schema_tool.get_table_constraints(table_name) == expected_table_result.constraints)
def test_schema_dump(test_fs): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") schema_tool = SchemaTool() expected_result = SchemaDump() with test_fs.open(['data', 'schema.json']) as f: expected_result.load(data=json.loads(f.read())) assert expected_result.defaults == schema_tool.get_defaults() for app_label in schema_tool.app_configs: expected_app_result = expected_result.get_app(app_label) for table_name in schema_tool.get_app_tables(app_label): expected_table_result = expected_app_result.get_table(table_name) assert (schema_tool.get_table_fields(table_name) == expected_table_result.fields) assert (schema_tool.get_table_indices(table_name) == expected_table_result.indices) assert (schema_tool.get_table_constraints(table_name) == expected_table_result.constraints)
def test_schema_tool(): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") schema_tool = SchemaTool() defaults = schema_tool.get_defaults() assert set(defaults.keys()) == TEST_MYSQL_SCHEMA_PARAM_NAMES['defaults'] for app_label in schema_tool.app_configs: for table in schema_tool.get_app_tables(app_label): row = schema_tool.get_table_fields(table).values()[0] assert ( set([x.lower() for x in row.keys()]).issubset( TEST_MYSQL_SCHEMA_PARAM_NAMES['tables']['fields']) ) row = schema_tool.get_table_indices(table).values()[0] assert ( set([x.lower() for x in row.keys()]).issubset( TEST_MYSQL_SCHEMA_PARAM_NAMES['tables']['indices']) ) row = schema_tool.get_table_constraints(table).values()[0] assert ( set([x.lower() for x in row.keys()]).issubset( TEST_MYSQL_SCHEMA_PARAM_NAMES['tables']['constraints']) )
def test_schema_wrong_app(): if get_current_db_type() != 'mysql': pytest.skip("unsupported database") with pytest.raises(CommandError): call_command('schema', 'app', 'wrong_app_name')