1
1
import { VirtualDocument } from '../../virtual/document' ;
2
2
import { expect } from 'chai' ;
3
- import { foreign_code_extractors , SQL_URL_PATTERN } from './extractors' ;
3
+ import { foreign_code_extractors } from './extractors' ;
4
4
import {
5
5
extract_code ,
6
- get_the_only_virtual ,
7
- wrap_in_python_lines
6
+ get_the_only_virtual
8
7
} from '../../extractors/testutils' ;
9
8
10
9
describe ( 'Bigquery SQL extractors' , ( ) => {
@@ -30,55 +29,6 @@ describe('Bigquery SQL extractors', () => {
30
29
document . clear ( ) ;
31
30
} ) ;
32
31
33
- /*
34
- describe('SQL url pattern', () => {
35
- it('matches connection strings', () => {
36
- const correct_urls = [
37
- 'mysql+pymysql://scott:tiger@localhost /foo',
38
- 'oracle://scott:[email protected] :1521/sidname',
39
- 'sqlite://',
40
- 'sqlite:///foo.db',
41
- 'mssql+pyodbc://username:password@host/database?driver=SQL+Server+Native+Client+11.0',
42
- 'impala://hserverhost:port/default?kerberos_service_name=hive&auth_mechanism=GSSAPI'
43
- ];
44
- const pattern = new RegExp(SQL_URL_PATTERN);
45
- for (let url of correct_urls) {
46
- expect(pattern.test(url)).to.equal(true);
47
- }
48
- });
49
- });
50
- */
51
- /* describe('%bigquery line magic', () => {
52
- it('extracts simple commands', () => {
53
- let code = wrap_in_python_lines('%bigquery select * from work');
54
- let { cell_code_kept, foreign_document_map } = extract(code);
55
-
56
- // should not be removed, but left for the static analysis (using magic overrides)
57
- expect(cell_code_kept).to.equal(code);
58
- let document = get_the_only_virtual(foreign_document_map);
59
- expect(document.language).to.equal('sql');
60
- expect(document.value).to.equal('select * from work\n');
61
- });*/
62
- /*
63
- it('leaves out the connection specification', () => {
64
- let code = wrap_in_python_lines(
65
- '%sql postgresql://will:longliveliz@localhost /shakes'
66
- );
67
- let foreign_document_map = extract(code).foreign_document_map;
68
- let document = get_the_only_virtual(foreign_document_map);
69
- expect(document.language).to.equal('sql');
70
- expect(document.value).to.equal('\n');
71
- });
72
-
73
- it('leaves out options', () => {
74
- let code = wrap_in_python_lines('%bigquery -l');
75
- let foreign_document_map = extract(code).foreign_document_map;
76
- let document = get_the_only_virtual(foreign_document_map);
77
- expect(document.language).to.equal('sql');
78
- expect(document.value).to.equal('\n');
79
- });
80
- });
81
- */
82
32
describe ( '%%bigquery cell magic' , ( ) => {
83
33
it ( 'extracts simple commands' , ( ) => {
84
34
let code = "%%bigquery\nselect * from character\nwhere abbrev = 'ALICE'" ;
@@ -91,46 +41,7 @@ describe('Bigquery SQL extractors', () => {
91
41
"select * from character\nwhere abbrev = 'ALICE'\n"
92
42
) ;
93
43
} ) ;
94
- /*
95
- it('leaves out the connection specification', () => {
96
- let code =
97
- "%%sql postgresql://will:longliveliz@localhost /shakes\nselect * from character\nwhere abbrev = 'ALICE'";
98
- let { foreign_document_map } = extract(code);
99
44
100
- let document = get_the_only_virtual(foreign_document_map);
101
- expect(document.language).to.equal('sql');
102
- expect(document.value).to.equal(
103
- "select * from character\nwhere abbrev = 'ALICE'\n"
104
- );
105
- });
106
-
107
-
108
- it('leaves out the variable assignment', () => {
109
- let code = '%%sql works << SELECT title, year\nFROM work';
110
- let { foreign_document_map } = extract(code);
111
-
112
- let document = get_the_only_virtual(foreign_document_map);
113
- expect(document.language).to.equal('sql');
114
- expect(document.value).to.equal('SELECT title, year\nFROM work\n');
115
- });
116
-
117
- it('leaves out existing connection references', () => {
118
- let code = '%%sql will@shakes \nSELECT title, year\nFROM work';
119
- let { foreign_document_map } = extract(code);
120
-
121
- let document = get_the_only_virtual(foreign_document_map);
122
- expect(document.language).to.equal('sql');
123
- expect(document.value).to.equal('SELECT title, year\nFROM work\n');
124
- });
125
- */
126
- /* it('leaves out persist option', () => {
127
- let code = '%%bigquery --persist dataframe\nSELECT * FROM dataframe;';
128
- let { foreign_document_map } = extract(code);
129
- let document = get_the_only_virtual(foreign_document_map);
130
- expect(document.language).to.equal('sql');
131
- expect(document.value).to.equal('SELECT * FROM dataframe;\n');
132
- });
133
- */
134
45
135
46
} ) ;
136
47
} ) ;
0 commit comments