forked from DistrictDataLabs/baleen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_export.py
52 lines (41 loc) · 1.51 KB
/
test_export.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# tests.test_export
# Test the export module - to generate a corpus for machine learning.
#
# Author: Benjamin Bengfort <[email protected]>
# Created: Sun Feb 21 15:49:18 2016 -0500
#
# Copyright (C) 2016 Bengfort.com
# For license information, see LICENSE.txt
#
# ID: test_export.py [2988c53] [email protected] $
"""
Test the export module - to generate a corpus for machine learning.
"""
##########################################################################
## Imports
##########################################################################
import unittest
try:
from unittest import mock
except ImportError:
import mock
from baleen.export import *
from baleen.exceptions import ExportError
##########################################################################
## Export Tests
##########################################################################
class ExportTests(unittest.TestCase):
def test_scheme_specification(self):
"""
Assert that only known schemes are allowed.
"""
# Make sure good schemes don't error
for scheme in SCHEMES:
try:
exporter = MongoExporter("/tmp/corpus", scheme=scheme)
except ExportError:
self.fail("Could not use expected scheme, {}".format(scheme))
# Make sure bad schemes do error
for scheme in ('text', 'txt', 'bson', 'xml', 'yaml'):
with self.assertRaises(ExportError):
exporter = MongoExporter("/tmp/corpus", scheme=scheme)