|
12 | 12 | # See the License for the specific language governing permissions and
|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
| 15 | +import os |
15 | 16 |
|
16 | 17 | import snippets
|
17 | 18 |
|
| 19 | +BUCKET = os.environ['CLOUD_STORAGE_BUCKET'] |
| 20 | +TEST_FILE_URL = 'gs://{}/text.txt'.format(BUCKET) |
18 | 21 |
|
19 |
| -def test_sentiment_text(cloud_config, capsys): |
| 22 | + |
| 23 | +def test_sentiment_text(capsys): |
20 | 24 | snippets.sentiment_text('President Obama is speaking at the White House.')
|
21 | 25 | out, _ = capsys.readouterr()
|
22 | 26 | assert 'Score: 0.2' in out
|
23 | 27 |
|
24 | 28 |
|
25 |
| -def test_sentiment_file(cloud_config, capsys): |
26 |
| - cloud_storage_input_uri = 'gs://{}/text.txt'.format( |
27 |
| - cloud_config.storage_bucket) |
28 |
| - snippets.sentiment_file(cloud_storage_input_uri) |
| 29 | +def test_sentiment_file(capsys): |
| 30 | + snippets.sentiment_file(TEST_FILE_URL) |
29 | 31 | out, _ = capsys.readouterr()
|
30 | 32 | assert 'Score: 0.2' in out
|
31 | 33 |
|
32 | 34 |
|
33 |
| -def test_entities_text(cloud_config, capsys): |
| 35 | +def test_entities_text(capsys): |
34 | 36 | snippets.entities_text('President Obama is speaking at the White House.')
|
35 | 37 | out, _ = capsys.readouterr()
|
36 | 38 | assert 'name' in out
|
37 | 39 | assert ': Obama' in out
|
38 | 40 |
|
39 | 41 |
|
40 |
| -def test_entities_file(cloud_config, capsys): |
41 |
| - cloud_storage_input_uri = 'gs://{}/text.txt'.format( |
42 |
| - cloud_config.storage_bucket) |
43 |
| - snippets.entities_file(cloud_storage_input_uri) |
| 42 | +def test_entities_file(capsys): |
| 43 | + snippets.entities_file(TEST_FILE_URL) |
44 | 44 | out, _ = capsys.readouterr()
|
45 | 45 | assert 'name' in out
|
46 | 46 | assert ': Obama' in out
|
47 | 47 |
|
48 | 48 |
|
49 |
| -def test_syntax_text(cloud_config, capsys): |
| 49 | +def test_syntax_text(capsys): |
50 | 50 | snippets.syntax_text('President Obama is speaking at the White House.')
|
51 | 51 | out, _ = capsys.readouterr()
|
52 | 52 | assert 'NOUN: President' in out
|
53 | 53 |
|
54 | 54 |
|
55 |
| -def test_syntax_file(cloud_config, capsys): |
56 |
| - cloud_storage_input_uri = 'gs://{}/text.txt'.format( |
57 |
| - cloud_config.storage_bucket) |
58 |
| - snippets.syntax_file(cloud_storage_input_uri) |
| 55 | +def test_syntax_file(capsys): |
| 56 | + snippets.syntax_file(TEST_FILE_URL) |
59 | 57 | out, _ = capsys.readouterr()
|
60 | 58 | assert 'NOUN: President' in out
|
0 commit comments