wjordan213-csvlint 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitattributes +2 -0
- data/.gitignore +28 -0
- data/.ruby-version +1 -0
- data/.travis.yml +32 -0
- data/CHANGELOG.md +361 -0
- data/Gemfile +7 -0
- data/LICENSE.md +22 -0
- data/README.md +328 -0
- data/Rakefile +17 -0
- data/bin/create_schema +32 -0
- data/bin/csvlint +10 -0
- data/features/check_format.feature +46 -0
- data/features/cli.feature +210 -0
- data/features/csv_options.feature +35 -0
- data/features/csvupload.feature +145 -0
- data/features/csvw_schema_validation.feature +127 -0
- data/features/fixtures/cr-line-endings.csv +0 -0
- data/features/fixtures/crlf-line-endings.csv +0 -0
- data/features/fixtures/inconsistent-line-endings-unquoted.csv +0 -0
- data/features/fixtures/inconsistent-line-endings.csv +0 -0
- data/features/fixtures/invalid-byte-sequence.csv +0 -0
- data/features/fixtures/invalid_many_rows.csv +0 -0
- data/features/fixtures/lf-line-endings.csv +0 -0
- data/features/fixtures/spreadsheet.xls +0 -0
- data/features/fixtures/spreadsheet.xlsx +0 -0
- data/features/fixtures/title-row.csv +0 -0
- data/features/fixtures/valid.csv +0 -0
- data/features/fixtures/valid_many_rows.csv +0 -0
- data/features/fixtures/windows-line-endings.csv +0 -0
- data/features/information.feature +22 -0
- data/features/parse_csv.feature +90 -0
- data/features/schema_validation.feature +105 -0
- data/features/sources.feature +17 -0
- data/features/step_definitions/cli_steps.rb +11 -0
- data/features/step_definitions/csv_options_steps.rb +24 -0
- data/features/step_definitions/information_steps.rb +13 -0
- data/features/step_definitions/parse_csv_steps.rb +42 -0
- data/features/step_definitions/schema_validation_steps.rb +33 -0
- data/features/step_definitions/sources_steps.rb +7 -0
- data/features/step_definitions/validation_errors_steps.rb +90 -0
- data/features/step_definitions/validation_info_steps.rb +22 -0
- data/features/step_definitions/validation_warnings_steps.rb +60 -0
- data/features/support/aruba.rb +56 -0
- data/features/support/env.rb +26 -0
- data/features/support/load_tests.rb +114 -0
- data/features/support/webmock.rb +1 -0
- data/features/validation_errors.feature +147 -0
- data/features/validation_info.feature +16 -0
- data/features/validation_warnings.feature +86 -0
- data/lib/csvlint.rb +27 -0
- data/lib/csvlint/cli.rb +165 -0
- data/lib/csvlint/csvw/column.rb +359 -0
- data/lib/csvlint/csvw/date_format.rb +182 -0
- data/lib/csvlint/csvw/metadata_error.rb +13 -0
- data/lib/csvlint/csvw/number_format.rb +211 -0
- data/lib/csvlint/csvw/property_checker.rb +761 -0
- data/lib/csvlint/csvw/table.rb +204 -0
- data/lib/csvlint/csvw/table_group.rb +165 -0
- data/lib/csvlint/error_collector.rb +27 -0
- data/lib/csvlint/error_message.rb +15 -0
- data/lib/csvlint/field.rb +196 -0
- data/lib/csvlint/schema.rb +92 -0
- data/lib/csvlint/validate.rb +599 -0
- data/lib/csvlint/version.rb +3 -0
- data/spec/csvw/column_spec.rb +112 -0
- data/spec/csvw/date_format_spec.rb +49 -0
- data/spec/csvw/number_format_spec.rb +417 -0
- data/spec/csvw/table_group_spec.rb +143 -0
- data/spec/csvw/table_spec.rb +90 -0
- data/spec/field_spec.rb +252 -0
- data/spec/schema_spec.rb +211 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/validator_spec.rb +619 -0
- data/wjordan213_csvlint.gemspec +46 -0
- metadata +490 -0
@@ -0,0 +1,210 @@
|
|
1
|
+
Feature: CSVlint CLI
|
2
|
+
|
3
|
+
Scenario: Valid CSV from url
|
4
|
+
Given I have a CSV with the following content:
|
5
|
+
"""
|
6
|
+
"Foo","Bar","Baz"
|
7
|
+
"1","2","3"
|
8
|
+
"3","2","1"
|
9
|
+
"""
|
10
|
+
And it is stored at the url "http://example.com/example1.csv"
|
11
|
+
When I run `csvlint http://example.com/example1.csv`
|
12
|
+
Then the output should contain "http://example.com/example1.csv is VALID"
|
13
|
+
|
14
|
+
Scenario: Valid CSV from file
|
15
|
+
When I run `csvlint ../../features/fixtures/valid.csv`
|
16
|
+
Then the output should contain "valid.csv is VALID"
|
17
|
+
|
18
|
+
# This is a hacky way of saying to run `cat features/fixtures/valid.csv | csvlint`
|
19
|
+
Scenario: Valid CSV from pipe
|
20
|
+
Given I have stubbed stdin to contain "features/fixtures/valid.csv"
|
21
|
+
When I run `csvlint`
|
22
|
+
Then the output should contain "CSV is VALID"
|
23
|
+
|
24
|
+
Scenario: URL that 404s
|
25
|
+
Given there is no file at the url "http://example.com/example1.csv"
|
26
|
+
And there is no file at the url "http://example.com/.well-known/csvm"
|
27
|
+
And there is no file at the url "http://example.com/example1.csv-metadata.json"
|
28
|
+
And there is no file at the url "http://example.com/csv-metadata.json"
|
29
|
+
When I run `csvlint http://example.com/example1.csv`
|
30
|
+
Then the output should contain "http://example.com/example1.csv is INVALID"
|
31
|
+
And the output should contain "not_found"
|
32
|
+
|
33
|
+
Scenario: File doesn't exist
|
34
|
+
When I run `csvlint ../../features/fixtures/non-existent-file.csv`
|
35
|
+
Then the output should contain "non-existent-file.csv not found"
|
36
|
+
|
37
|
+
Scenario: No file or URL specified
|
38
|
+
Given I have stubbed stdin to contain nothing
|
39
|
+
When I run `csvlint`
|
40
|
+
Then the output should contain "No CSV data to validate"
|
41
|
+
|
42
|
+
Scenario: No file or URL specified, but schema specified
|
43
|
+
Given I have stubbed stdin to contain nothing
|
44
|
+
And I have a schema with the following content:
|
45
|
+
"""
|
46
|
+
{
|
47
|
+
"fields": [
|
48
|
+
{ "name": "Name", "constraints": { "required": true } },
|
49
|
+
{ "name": "Id", "constraints": { "required": true, "minLength": 1 } },
|
50
|
+
{ "name": "Email", "constraints": { "required": true } }
|
51
|
+
]
|
52
|
+
}
|
53
|
+
"""
|
54
|
+
And the schema is stored at the url "http://example.com/schema.json"
|
55
|
+
When I run `csvlint --schema http://example.com/schema.json`
|
56
|
+
Then the output should contain "No CSV data to validate"
|
57
|
+
|
58
|
+
Scenario: Invalid CSV from url
|
59
|
+
Given I have a CSV with the following content:
|
60
|
+
"""
|
61
|
+
"Foo", "Bar" , "Baz"
|
62
|
+
"""
|
63
|
+
And it is stored at the url "http://example.com/example1.csv"
|
64
|
+
When I run `csvlint http://example.com/example1.csv`
|
65
|
+
Then the output should contain "http://example.com/example1.csv is INVALID"
|
66
|
+
And the output should contain "whitespace"
|
67
|
+
|
68
|
+
Scenario: Specify schema
|
69
|
+
Given I have a CSV with the following content:
|
70
|
+
"""
|
71
|
+
"Bob","1234","bob@example.org"
|
72
|
+
"Alice","5","alice@example.com"
|
73
|
+
"""
|
74
|
+
And it is stored at the url "http://example.com/example1.csv"
|
75
|
+
And I have a schema with the following content:
|
76
|
+
"""
|
77
|
+
{
|
78
|
+
"fields": [
|
79
|
+
{ "name": "Name", "constraints": { "required": true } },
|
80
|
+
{ "name": "Id", "constraints": { "required": true, "minLength": 1 } },
|
81
|
+
{ "name": "Email", "constraints": { "required": true } }
|
82
|
+
]
|
83
|
+
}
|
84
|
+
"""
|
85
|
+
And the schema is stored at the url "http://example.com/schema.json"
|
86
|
+
When I run `csvlint http://example.com/example1.csv --schema http://example.com/schema.json`
|
87
|
+
Then the output should contain "http://example.com/example1.csv is VALID"
|
88
|
+
|
89
|
+
Scenario: Schema errors
|
90
|
+
Given I have a CSV with the following content:
|
91
|
+
"""
|
92
|
+
"Bob","1234","bob@example.org"
|
93
|
+
"Alice","5","alice@example.com"
|
94
|
+
"""
|
95
|
+
And it is stored at the url "http://example.com/example1.csv"
|
96
|
+
And I have a schema with the following content:
|
97
|
+
"""
|
98
|
+
{
|
99
|
+
"fields": [
|
100
|
+
{ "name": "Name", "constraints": { "required": true } },
|
101
|
+
{ "name": "Id", "constraints": { "required": true, "minLength": 3 } },
|
102
|
+
{ "name": "Email", "constraints": { "required": true } }
|
103
|
+
]
|
104
|
+
}
|
105
|
+
"""
|
106
|
+
And the schema is stored at the url "http://example.com/schema.json"
|
107
|
+
When I run `csvlint http://example.com/example1.csv --schema http://example.com/schema.json`
|
108
|
+
Then the output should contain "http://example.com/example1.csv is INVALID"
|
109
|
+
And the output should contain "1. Id: min_length. Row: 2,2. 5"
|
110
|
+
And the output should contain "1. malformed_header. Row: 1. Bob,1234,bob@example.org"
|
111
|
+
|
112
|
+
Scenario: Invalid schema
|
113
|
+
Given I have a CSV with the following content:
|
114
|
+
"""
|
115
|
+
"Bob","1234","bob@example.org"
|
116
|
+
"Alice","5","alice@example.com"
|
117
|
+
"""
|
118
|
+
And it is stored at the url "http://example.com/example1.csv"
|
119
|
+
And I have a schema with the following content:
|
120
|
+
"""
|
121
|
+
NO JSON HERE SON
|
122
|
+
"""
|
123
|
+
And the schema is stored at the url "http://example.com/schema.json"
|
124
|
+
Then nothing should be outputted to STDERR
|
125
|
+
When I run `csvlint http://example.com/example1.csv --schema http://example.com/schema.json`
|
126
|
+
And the output should contain "invalid metadata: malformed JSON"
|
127
|
+
|
128
|
+
Scenario: Schema that 404s
|
129
|
+
Given I have a CSV with the following content:
|
130
|
+
"""
|
131
|
+
"Bob","1234","bob@example.org"
|
132
|
+
"Alice","5","alice@example.com"
|
133
|
+
"""
|
134
|
+
And it is stored at the url "http://example.com/example1.csv"
|
135
|
+
And there is no file at the url "http://example.com/schema404.json"
|
136
|
+
When I run `csvlint http://example.com/example1.csv --schema http://example.com/schema404.json`
|
137
|
+
Then the output should contain "http://example.com/schema404.json not found"
|
138
|
+
|
139
|
+
Scenario: Schema that doesn't exist
|
140
|
+
Given I have a CSV with the following content:
|
141
|
+
"""
|
142
|
+
"Bob","1234","bob@example.org"
|
143
|
+
"Alice","5","alice@example.com"
|
144
|
+
"""
|
145
|
+
And it is stored at the url "http://example.com/example1.csv"
|
146
|
+
When I run `csvlint http://example.com/example1.csv --schema /fake/file/path.json`
|
147
|
+
Then the output should contain "/fake/file/path.json not found"
|
148
|
+
|
149
|
+
Scenario: Valid CSVw schema
|
150
|
+
Given I have a CSV with the following content:
|
151
|
+
"""
|
152
|
+
"Bob","1234","bob@example.org"
|
153
|
+
"Alice","5","alice@example.com"
|
154
|
+
"""
|
155
|
+
And it is stored at the url "http://example.com/example1.csv"
|
156
|
+
And I have metadata with the following content:
|
157
|
+
"""
|
158
|
+
{
|
159
|
+
"@context": "http://www.w3.org/ns/csvw",
|
160
|
+
"url": "http://example.com/example1.csv",
|
161
|
+
"dialect": { "header": false },
|
162
|
+
"tableSchema": {
|
163
|
+
"columns": [
|
164
|
+
{ "name": "Name", "required": true },
|
165
|
+
{ "name": "Id", "required": true, "datatype": { "base": "string", "minLength": 1 } },
|
166
|
+
{ "name": "Email", "required": true }
|
167
|
+
]
|
168
|
+
}
|
169
|
+
}
|
170
|
+
"""
|
171
|
+
And the schema is stored at the url "http://example.com/schema.json"
|
172
|
+
When I run `csvlint http://example.com/example1.csv --schema http://example.com/schema.json`
|
173
|
+
Then the output should contain "http://example.com/example1.csv is VALID"
|
174
|
+
|
175
|
+
Scenario: CSVw schema with invalid CSV
|
176
|
+
Given I have a CSV with the following content:
|
177
|
+
"""
|
178
|
+
"Bob","1234","bob@example.org"
|
179
|
+
"Alice","5","alice@example.com"
|
180
|
+
"""
|
181
|
+
And it is stored at the url "http://example.com/example1.csv"
|
182
|
+
And I have metadata with the following content:
|
183
|
+
"""
|
184
|
+
{
|
185
|
+
"@context": "http://www.w3.org/ns/csvw",
|
186
|
+
"url": "http://example.com/example1.csv",
|
187
|
+
"dialect": { "header": false },
|
188
|
+
"tableSchema": {
|
189
|
+
"columns": [
|
190
|
+
{ "name": "Name", "required": true },
|
191
|
+
{ "name": "Id", "required": true, "datatype": { "base": "string", "minLength": 3 } },
|
192
|
+
{ "name": "Email", "required": true }
|
193
|
+
]
|
194
|
+
}
|
195
|
+
}
|
196
|
+
"""
|
197
|
+
And the schema is stored at the url "http://example.com/schema.json"
|
198
|
+
When I run `csvlint http://example.com/example1.csv --schema http://example.com/schema.json`
|
199
|
+
Then the output should contain "http://example.com/example1.csv is INVALID"
|
200
|
+
And the output should contain "1. min_length. Row: 2,2. 5"
|
201
|
+
|
202
|
+
Scenario: CSVw table Schema
|
203
|
+
Given I have stubbed stdin to contain nothing
|
204
|
+
And I have a metadata file called "csvw/countries.json"
|
205
|
+
And the metadata is stored at the url "http://w3c.github.io/csvw/tests/countries.json"
|
206
|
+
And I have a file called "csvw/countries.csv" at the url "http://w3c.github.io/csvw/tests/countries.csv"
|
207
|
+
And I have a file called "csvw/country_slice.csv" at the url "http://w3c.github.io/csvw/tests/country_slice.csv"
|
208
|
+
When I run `csvlint --schema http://w3c.github.io/csvw/tests/countries.json`
|
209
|
+
Then the output should contain "http://w3c.github.io/csvw/tests/countries.csv is VALID"
|
210
|
+
And the output should contain "http://w3c.github.io/csvw/tests/country_slice.csv is VALID"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Feature: CSV options
|
2
|
+
|
3
|
+
Scenario: Sucessfully parse a valid CSV
|
4
|
+
Given I have a CSV with the following content:
|
5
|
+
"""
|
6
|
+
'Foo';'Bar';'Baz'
|
7
|
+
'1';'2';'3'
|
8
|
+
'3';'2';'1'
|
9
|
+
"""
|
10
|
+
And I set the delimiter to ";"
|
11
|
+
And I set quotechar to "'"
|
12
|
+
And it is stored at the url "http://example.com/example1.csv"
|
13
|
+
When I ask if the CSV is valid
|
14
|
+
Then I should get the value of true
|
15
|
+
|
16
|
+
Scenario: Warn if options seem to return invalid data
|
17
|
+
Given I have a CSV with the following content:
|
18
|
+
"""
|
19
|
+
'Foo';'Bar';'Baz'
|
20
|
+
'1';'2';'3'
|
21
|
+
'3';'2';'1'
|
22
|
+
"""
|
23
|
+
And I set the delimiter to ","
|
24
|
+
And I set quotechar to """
|
25
|
+
And it is stored at the url "http://example.com/example1.csv"
|
26
|
+
And I ask if there are warnings
|
27
|
+
Then there should be 1 warnings
|
28
|
+
And that warning should have the type "check_options"
|
29
|
+
|
30
|
+
Scenario: Use esoteric line endings
|
31
|
+
Given I have a CSV file called "windows-line-endings.csv"
|
32
|
+
And it is stored at the url "http://example.com/example1.csv"
|
33
|
+
When I ask if the CSV is valid
|
34
|
+
Then I should get the value of true
|
35
|
+
|
@@ -0,0 +1,145 @@
|
|
1
|
+
Feature: Collect all the tests that should trigger dialect check related errors
|
2
|
+
|
3
|
+
Scenario: Title rows, I wish to trigger a :title_row type message
|
4
|
+
Given I have a CSV file called "title-row.csv"
|
5
|
+
And it is stored at the url "http://example.com/example1.csv"
|
6
|
+
And I ask if there are warnings
|
7
|
+
Then there should be 1 warnings
|
8
|
+
And that warning should have the type "title_row"
|
9
|
+
|
10
|
+
# :nonrfc_line_breaks
|
11
|
+
|
12
|
+
Scenario: LF line endings in file give an info message of type :nonrfc_line_breaks
|
13
|
+
Given I have a CSV file called "lf-line-endings.csv"
|
14
|
+
And it is stored at the url "http://example.com/example1.csv"
|
15
|
+
And I set header to "true"
|
16
|
+
And I ask if there are info messages
|
17
|
+
Then there should be 1 info message
|
18
|
+
And one of the messages should have the type "nonrfc_line_breaks"
|
19
|
+
|
20
|
+
Scenario: CRLF line endings in file produces no info messages of type :nonrfc_line_breaks
|
21
|
+
Given I have a CSV file called "crlf-line-endings.csv"
|
22
|
+
And it is stored at the url "http://example.com/example1.csv"
|
23
|
+
And I set header to "true"
|
24
|
+
And I ask if there are info messages
|
25
|
+
Then there should be 0 info messages
|
26
|
+
|
27
|
+
# :line_breaks
|
28
|
+
|
29
|
+
Scenario: Incorrect line endings specified in settings
|
30
|
+
Given I have a CSV file called "lf-line-endings.csv"
|
31
|
+
And I set the line endings to carriage return
|
32
|
+
And it is stored at the url "http://example.com/example1.csv"
|
33
|
+
And I ask if there are errors
|
34
|
+
Then there should be 1 error
|
35
|
+
And that error should have the type "line_breaks"
|
36
|
+
|
37
|
+
Scenario: inconsistent line endings in file cause an error
|
38
|
+
Given I have a CSV file called "inconsistent-line-endings.csv"
|
39
|
+
And it is stored at the url "http://example.com/example1.csv"
|
40
|
+
And I ask if there are errors
|
41
|
+
Then there should be 1 error
|
42
|
+
And that error should have the type "line_breaks"
|
43
|
+
|
44
|
+
|
45
|
+
Scenario: inconsistent line endings with unquoted fields in file cause an error
|
46
|
+
Given I have a CSV file called "inconsistent-line-endings-unquoted.csv"
|
47
|
+
And it is stored at the url "http://example.com/example1.csv"
|
48
|
+
And I ask if there are errors
|
49
|
+
Then there should be 1 error
|
50
|
+
And that error should have the type "line_breaks"
|
51
|
+
|
52
|
+
#:unclosed_quote
|
53
|
+
|
54
|
+
Scenario: CSV with incorrect quoting
|
55
|
+
Given I have a CSV with the following content:
|
56
|
+
"""
|
57
|
+
"col1","col2","col3"
|
58
|
+
"Foo","Bar","Baz
|
59
|
+
"""
|
60
|
+
And it is stored at the url "http://example.com/example1.csv"
|
61
|
+
When I ask if there are errors
|
62
|
+
Then there should be 1 error
|
63
|
+
And that error should have the type "unclosed_quote"
|
64
|
+
And that error should have the row "2"
|
65
|
+
And that error should have the content ""Foo","Bar","Baz"
|
66
|
+
|
67
|
+
# :invalid_encoding
|
68
|
+
|
69
|
+
Scenario: Report invalid Encoding
|
70
|
+
Given I have a CSV file called "invalid-byte-sequence.csv"
|
71
|
+
And I set an encoding header of "UTF-8"
|
72
|
+
And it is stored at the url "http://example.com/example1.csv"
|
73
|
+
When I ask if there are errors
|
74
|
+
Then there should be 1 error
|
75
|
+
And that error should have the type "invalid_encoding"
|
76
|
+
|
77
|
+
Scenario: Report invalid file
|
78
|
+
#should this throw an excel error?
|
79
|
+
Given I have a CSV file called "spreadsheet.xls"
|
80
|
+
And it is stored at the url "http://example.com/example1.csv"
|
81
|
+
When I ask if there are errors
|
82
|
+
Then there should be 1 error
|
83
|
+
And that error should have the type "invalid_encoding"
|
84
|
+
|
85
|
+
# :blank_rows
|
86
|
+
|
87
|
+
Scenario: Successfully report a CSV with blank rows
|
88
|
+
Given I have a CSV with the following content:
|
89
|
+
"""
|
90
|
+
"col1","col2","col3"
|
91
|
+
"Foo","Bar","Baz"
|
92
|
+
"","",
|
93
|
+
"Baz","Bar","Foo"
|
94
|
+
"""
|
95
|
+
And it is stored at the url "http://example.com/example1.csv"
|
96
|
+
When I ask if there are errors
|
97
|
+
Then there should be 1 error
|
98
|
+
And that error should have the type "blank_rows"
|
99
|
+
And that error should have the row "3"
|
100
|
+
And that error should have the content ""","","
|
101
|
+
|
102
|
+
Scenario: Successfully report a CSV with multiple trailing empty rows
|
103
|
+
Given I have a CSV with the following content:
|
104
|
+
"""
|
105
|
+
"col1","col2","col3"
|
106
|
+
"Foo","Bar","Baz"
|
107
|
+
"Foo","Bar","Baz"
|
108
|
+
|
109
|
+
|
110
|
+
"""
|
111
|
+
And it is stored at the url "http://example.com/example1.csv"
|
112
|
+
When I ask if there are errors
|
113
|
+
Then there should be 1 error
|
114
|
+
And that error should have the type "blank_rows"
|
115
|
+
And that error should have the row "4"
|
116
|
+
|
117
|
+
Scenario: Successfully report a CSV with an empty row
|
118
|
+
Given I have a CSV with the following content:
|
119
|
+
"""
|
120
|
+
"col1","col2","col3"
|
121
|
+
"Foo","Bar","Baz"
|
122
|
+
|
123
|
+
"Foo","Bar","Baz"
|
124
|
+
"""
|
125
|
+
And it is stored at the url "http://example.com/example1.csv"
|
126
|
+
When I ask if there are errors
|
127
|
+
Then there should be 1 error
|
128
|
+
And that error should have the type "blank_rows"
|
129
|
+
And that error should have the row "3"
|
130
|
+
|
131
|
+
#:check_options
|
132
|
+
|
133
|
+
Scenario: Warn if options seem to return invalid data
|
134
|
+
Given I have a CSV with the following content:
|
135
|
+
"""
|
136
|
+
'Foo';'Bar';'Baz'
|
137
|
+
'1';'2';'3'
|
138
|
+
'3';'2';'1'
|
139
|
+
"""
|
140
|
+
And I set the delimiter to ","
|
141
|
+
And I set quotechar to """
|
142
|
+
And it is stored at the url "http://example.com/example1.csv"
|
143
|
+
And I ask if there are warnings
|
144
|
+
Then there should be 1 warnings
|
145
|
+
And that warning should have the type "check_options"
|
@@ -0,0 +1,127 @@
|
|
1
|
+
Feature: CSVW Schema Validation
|
2
|
+
|
3
|
+
Scenario: Valid CSV
|
4
|
+
Given I have a CSV with the following content:
|
5
|
+
"""
|
6
|
+
"Bob","1234","bob@example.org"
|
7
|
+
"Alice","5","alice@example.com"
|
8
|
+
"""
|
9
|
+
And it is stored at the url "http://example.com/example1.csv"
|
10
|
+
And I have metadata with the following content:
|
11
|
+
"""
|
12
|
+
{
|
13
|
+
"@context": "http://www.w3.org/ns/csvw",
|
14
|
+
"url": "http://example.com/example1.csv",
|
15
|
+
"dialect": { "header": false },
|
16
|
+
"tableSchema": {
|
17
|
+
"columns": [
|
18
|
+
{ "name": "Name", "required": true },
|
19
|
+
{ "name": "Id", "required": true, "datatype": { "base": "string", "minLength": 1 } },
|
20
|
+
{ "name": "Email", "required": true }
|
21
|
+
]
|
22
|
+
}
|
23
|
+
}
|
24
|
+
"""
|
25
|
+
When I ask if there are errors
|
26
|
+
Then there should be 0 error
|
27
|
+
|
28
|
+
Scenario: Schema invalid CSV
|
29
|
+
Given I have a CSV with the following content:
|
30
|
+
"""
|
31
|
+
"Bob","1234","bob@example.org"
|
32
|
+
"Alice","5","alice@example.com"
|
33
|
+
"""
|
34
|
+
And it is stored at the url "http://example.com/example1.csv"
|
35
|
+
And I have metadata with the following content:
|
36
|
+
"""
|
37
|
+
{
|
38
|
+
"@context": "http://www.w3.org/ns/csvw",
|
39
|
+
"url": "http://example.com/example1.csv",
|
40
|
+
"dialect": { "header": false },
|
41
|
+
"tableSchema": {
|
42
|
+
"columns": [
|
43
|
+
{ "name": "Name", "required": true },
|
44
|
+
{ "name": "Id", "required": true, "datatype": { "base": "string", "minLength": 3 } },
|
45
|
+
{ "name": "Email", "required": true }
|
46
|
+
]
|
47
|
+
}
|
48
|
+
}
|
49
|
+
"""
|
50
|
+
When I ask if there are errors
|
51
|
+
Then there should be 1 error
|
52
|
+
|
53
|
+
Scenario: CSV with incorrect header
|
54
|
+
Given I have a CSV with the following content:
|
55
|
+
"""
|
56
|
+
"name","id","contact"
|
57
|
+
"Bob","1234","bob@example.org"
|
58
|
+
"Alice","5","alice@example.com"
|
59
|
+
"""
|
60
|
+
And it is stored at the url "http://example.com/example1.csv"
|
61
|
+
And I have metadata with the following content:
|
62
|
+
"""
|
63
|
+
{
|
64
|
+
"@context": "http://www.w3.org/ns/csvw",
|
65
|
+
"url": "http://example.com/example1.csv",
|
66
|
+
"tableSchema": {
|
67
|
+
"columns": [
|
68
|
+
{ "titles": "name", "required": true },
|
69
|
+
{ "titles": "id", "required": true, "datatype": { "base": "string", "minLength": 1 } },
|
70
|
+
{ "titles": "email", "required": true }
|
71
|
+
]
|
72
|
+
}
|
73
|
+
}
|
74
|
+
"""
|
75
|
+
When I ask if there are errors
|
76
|
+
Then there should be 1 error
|
77
|
+
|
78
|
+
Scenario: Schema with valid regex
|
79
|
+
Given I have a CSV with the following content:
|
80
|
+
"""
|
81
|
+
"firstname","id","email"
|
82
|
+
"Bob","1234","bob@example.org"
|
83
|
+
"Alice","5","alice@example.com"
|
84
|
+
"""
|
85
|
+
And it is stored at the url "http://example.com/example1.csv"
|
86
|
+
And I have metadata with the following content:
|
87
|
+
"""
|
88
|
+
{
|
89
|
+
"@context": "http://www.w3.org/ns/csvw",
|
90
|
+
"url": "http://example.com/example1.csv",
|
91
|
+
"tableSchema": {
|
92
|
+
"columns": [
|
93
|
+
{ "titles": "firstname", "required": true, "datatype": { "base": "string", "format": "^[A-Za-z0-9_]*$" } },
|
94
|
+
{ "titles": "id", "required": true, "datatype": { "base": "string", "minLength": 1 } },
|
95
|
+
{ "titles": "email", "required": true }
|
96
|
+
]
|
97
|
+
}
|
98
|
+
}
|
99
|
+
"""
|
100
|
+
When I ask if there are warnings
|
101
|
+
Then there should be 0 warnings
|
102
|
+
|
103
|
+
Scenario: Schema with invalid regex
|
104
|
+
Given I have a CSV with the following content:
|
105
|
+
"""
|
106
|
+
"firstname","id","email"
|
107
|
+
"Bob","1234","bob@example.org"
|
108
|
+
"Alice","5","alice@example.com"
|
109
|
+
"""
|
110
|
+
And it is stored at the url "http://example.com/example1.csv"
|
111
|
+
And I have metadata with the following content:
|
112
|
+
"""
|
113
|
+
{
|
114
|
+
"@context": "http://www.w3.org/ns/csvw",
|
115
|
+
"url": "http://example.com/example1.csv",
|
116
|
+
"tableSchema": {
|
117
|
+
"columns": [
|
118
|
+
{ "titles": "firstname", "required": true, "datatype": { "base": "string", "format": "((" } },
|
119
|
+
{ "titles": "id", "required": true, "datatype": { "base": "string", "minLength": 1 } },
|
120
|
+
{ "titles": "email", "required": true }
|
121
|
+
]
|
122
|
+
}
|
123
|
+
}
|
124
|
+
"""
|
125
|
+
When I ask if there are warnings
|
126
|
+
Then there should be 1 warnings
|
127
|
+
And that warning should have the type "invalid_regex"
|