from charts.utils import sql_format def test_sql_and_defaut(): """Test sql_and without any terms.""" response = sql_format.sql_and([]) assert response == '(TRUE)' def test_sql_and_custom_defaut(): """Test sql_and without any terms and a custom default.""" response = sql_format.sql_and([], default='FALSE') assert response == '(FALSE)' def test_sql_and_one(): """Test sql_and with one term.""" response = sql_format.sql_and(['SQL 1']) assert response == '((SQL 1))' def test_sql_and_many(): """Test sql_and with many term =s.""" response = sql_format.sql_and(['SQL 1', 'SQL 2', 'SQL 3']) assert response == '((SQL 1) AND (SQL 2) AND (SQL 3))' def test_sql_or_defaut(): """Test sql_or without any terms.""" response = sql_format.sql_or([]) assert response == '(FALSE)' def test_sql_or_custom_defaut(): """Test sql_or without any terms ord a custom default.""" response = sql_format.sql_or([], default='TRUE') assert response == '(TRUE)' def test_sql_or_one(): """Test sql_or with one term.""" response = sql_format.sql_or(['SQL 1']) assert response == '((SQL 1))' def test_sql_or_many(): """Test sql_or with many term =s.""" response = sql_format.sql_or(['SQL 1', 'SQL 2', 'SQL 3']) assert response == '((SQL 1) OR (SQL 2) OR (SQL 3))'