server: split BoolExpBasic tests into common and backend-specific classes

GitOrigin-RevId: 9e62260881de63e5f89007bb1d6607254625cda7
This commit is contained in:
Abby Sassel 2021-03-17 10:56:07 +00:00 committed by hasura-bot
parent 91710bba58
commit 89d838b85a
10 changed files with 362 additions and 28 deletions

View File

@ -0,0 +1,173 @@
type: bulk
args:
#Author table
- type: mssql_run_sql
args:
source: mssql
sql: |
CREATE TABLE author(
id int identity NOT NULL PRIMARY KEY,
[name] varchar(450) UNIQUE,
[is_registered] bit NOT NULL DEFAULT 0
);
INSERT INTO
author([name], [is_registered])
VALUES
('Author 1', 1),
('Author 2', 1),
('Author 3', 0);
CREATE TABLE article (
id int identity NOT NULL PRIMARY KEY,
title TEXT,
content TEXT,
author_id INTEGER REFERENCES author(id),
is_published bit,
published_on DATETIME
);
CREATE TABLE city (
id int identity NOT NULL PRIMARY KEY,
[name] TEXT NOT NULL,
country TEXT NOT NULL
);
INSERT INTO
city ([name], country)
VALUES
('Durham', 'USA'),
('New York', 'USA'),
('Framlingham', 'UK'),
('New Orleans', 'USA');
CREATE TABLE orders (
id int identity NOT NULL PRIMARY KEY,
received_at DATETIME NOT NULL,
delivered_at DATETIME
);
INSERT INTO
orders (received_at, delivered_at)
VALUES
('2018-09-21T09:39:44', NULL),
('2018-09-21T09:40:44', '2018-09-21T09:50:44');
CREATE TABLE message (
id int PRIMARY KEY,
content TEXT NOT NULL,
parent_id INT NULL
);
INSERT INTO
message (id, content, parent_id)
VALUES
(
1,
'hello world',
DEFAULT
),
(
2,
'content 2',
1
),
(
3,
'content 3',
1
),
(
4,
'ahoy',
DEFAULT
),
(
5,
'content 5',
4
),
(
6,
'hello three',
4
);
ALTER TABLE
message
ADD
CONSTRAINT parent_fk FOREIGN KEY (parent_id) REFERENCES message(id);
INSERT INTO
article (title, content, author_id, is_published)
VALUES
(
'Article 1',
'Sample article content 1',
1,
0
),
(
'Article 2',
'Sample article content 2',
1,
1
),
(
'Article 3',
'Sample article content 3',
2,
0
),
(
'Article 4',
'Sample article content 4',
3,
1
);
CREATE TABLE [uuid_test] (
id int identity NOT NULL PRIMARY KEY,
uuid_col uniqueidentifier NOT NULL
);
CREATE TABLE [user] (
id int identity NOT NULL PRIMARY KEY,
[name] varchar(450) NOT NULL UNIQUE,
is_admin bit DEFAULT 0
);
INSERT INTO
[user] ([name], is_admin)
VALUES
('user_1', 0),
('user_2', 1);
CREATE TABLE account (
id int identity NOT NULL PRIMARY KEY,
account_no integer NOT NULL UNIQUE
);
INSERT INTO
account (account_no)
VALUES
(1),
(2);
CREATE TABLE table_with_sql_identifier (
id int identity NOT NULL PRIMARY KEY,
sql_id text
);
INSERT INTO
table_with_sql_identifier (sql_id)
VALUES
('one'),
('one'),
('two'),
('three'),
('four'),
('one'),
('two');

View File

@ -0,0 +1,16 @@
type: bulk
args:
- type: mssql_run_sql
args:
source: mssql
sql: |
DROP TABLE table_with_sql_identifier;
DROP TABLE article;
DROP TABLE author;
DROP TABLE city;
DROP TABLE orders;
DROP TABLE message;
DROP TABLE uuid_test;
DROP TABLE "user";
DROP TABLE account;
cascade: true

View File

@ -0,0 +1,24 @@
description: Select author and their articles
url: /v1/graphql
status: 200
response:
errors:
- extensions:
code: validation-failed
path: $.selectionSet.author.args.where.name._ne
message: |-
field "_ne" not found in type: 'String_MSSQL_comparison_exp'
query:
query: |
query {
author (where: {name: {_ne: "Author 1"}}) {
id
name
articles {
id
title
content
is_published
}
}
}

View File

@ -5,8 +5,8 @@ response:
data:
orders:
- id: 2
received_at: '2018-09-21T09:40:44+00:00'
delivered_at: '2018-09-21T09:50:44+00:00'
received_at: '2018-09-21T09:40:44'
delivered_at: '2018-09-21T09:50:44'
query:
query: |
query {

View File

@ -5,7 +5,7 @@ response:
data:
orders:
- id: 1
received_at: '2018-09-21T09:39:44+00:00'
received_at: '2018-09-21T09:39:44'
query:
query: |
query {

View File

@ -44,8 +44,8 @@ args:
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
received_at TIMESTAMP WITH TIME ZONE NOT NULL,
delivered_at TIMESTAMP WITH TIME ZONE
received_at TIMESTAMP NOT NULL,
delivered_at TIMESTAMP
);
CREATE TABLE message (
@ -215,9 +215,9 @@ args:
args:
table: orders
objects:
- received_at: '2018-09-21T09:39:44Z'
- received_at: '2018-09-21T09:40:44Z'
delivered_at: '2018-09-21T09:50:44Z'
- received_at: '2018-09-21T09:39:44'
- received_at: '2018-09-21T09:40:44'
delivered_at: '2018-09-21T09:50:44'
- type: track_table
args:

View File

@ -0,0 +1,100 @@
type: bulk
args:
# Track tables
- type: mssql_track_table
args:
source: mssql
table:
name: author
- type: mssql_track_table
args:
source: mssql
table:
name: article
- type: mssql_track_table
args:
source: mssql
table:
name: city
- type: mssql_track_table
args:
source: mssql
table:
name: orders
- type: mssql_track_table
args:
source: mssql
table:
name: message
- type: mssql_track_table
args:
source: mssql
table:
name: uuid_test
- type: mssql_track_table
args:
source: mssql
table:
name: user
- type: mssql_track_table
args:
source: mssql
table:
name: account
- type: mssql_track_table
args:
source: mssql
table:
name: table_with_sql_identifier
#Object relationships
- type: mssql_create_object_relationship
args:
source: mssql
table: article
name: author
using:
foreign_key_constraint_on: author_id
- type: mssql_create_object_relationship
args:
source: mssql
table: message
name: parent
using:
foreign_key_constraint_on: parent_id
#Array relationships
- type: mssql_create_array_relationship
args:
source: mssql
table: author
name: articles
using:
foreign_key_constraint_on:
table: article
column: author_id
- type: mssql_create_array_relationship
args:
source: mssql
table: message
name: children
using:
foreign_key_constraint_on:
table: message
column: parent_id

View File

@ -0,0 +1,2 @@
type: bulk
args: []

View File

@ -240,15 +240,19 @@ class TestGraphQLQueryOffsets:
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_class_tests_db_state')
class TestGraphQLQueryBoolExpBasic:
@pytest.mark.parametrize("backend", ['mssql', 'postgres'])
@usefixtures('per_class_tests_db_state', 'per_backend_tests')
class TestGraphQLQueryBoolExpBasicCommon:
def test_order_delivered_at_is_null(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_query_order_delivered_at_is_null.yaml', transport)
def test_order_delivered_at_is_not_null(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_query_order_delivered_at_is_not_null.yaml', transport)
def test_author_article_where_not_equal(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_neq.yaml', transport)
def test_author_article_operator_ne_not_found_err(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_operator_ne_not_found_err.yaml', transport)
def test_author_article_where_greater_than(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_gt.yaml', transport)
@ -258,9 +262,29 @@ class TestGraphQLQueryBoolExpBasic:
def test_author_article_where_less_than(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_lt.yaml', transport)
def test_author_article_where_not_less_than(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_not_lt.yaml', transport)
def test_author_article_where_less_than_or_equal(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_lte.yaml', transport)
def test_article_author_is_published_and_registered(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_article_author_is_published_and_registered.yaml', transport)
def test_article_author_not_published_nor_registered(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_article_author_not_published_or_not_registered.yaml', transport)
@classmethod
def dir(cls):
return 'queries/graphql_query/boolexp/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['postgres'])
@usefixtures('per_class_tests_db_state', 'per_backend_tests')
class TestGraphQLQueryBoolExpBasicPostgres:
def test_author_article_operator_ne_not_found_err(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_operator_ne_not_found_err_postgres.yaml', transport)
def test_author_article_where_in(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_in.yaml', transport)
@ -276,21 +300,6 @@ class TestGraphQLQueryBoolExpBasic:
def test_uuid_test_in_uuid_col(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_uuid_test_in_uuid_col.yaml', transport)
def test_order_delivered_at_is_null(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_query_order_delivered_at_is_null.yaml', transport)
def test_order_delivered_at_is_not_null(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_query_order_delivered_at_is_not_null.yaml', transport)
def test_author_article_where_not_less_than(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_where_not_lt.yaml', transport)
def test_article_author_is_published_and_registered(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_article_author_is_published_and_registered.yaml', transport)
def test_article_author_not_published_nor_registered(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_article_author_not_published_or_not_registered.yaml', transport)
def test_article_author_unexpected_operator_in_where_err(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_unexpected_operator_in_where_err.yaml', transport)
@ -310,6 +319,16 @@ class TestGraphQLQueryBoolExpBasic:
def dir(cls):
return 'queries/graphql_query/boolexp/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@pytest.mark.parametrize("backend", ['mssql'])
@usefixtures('per_class_tests_db_state', 'per_backend_tests')
class TestGraphQLQueryBoolExpBasicMSSQL:
def test_author_article_operator_ne_not_found_err(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_author_article_operator_ne_not_found_err_mssql.yaml', transport)
@classmethod
def dir(cls):
return 'queries/graphql_query/boolexp/basic'
@pytest.mark.parametrize("transport", ['http', 'websocket'])
@usefixtures('per_class_tests_db_state')