Browse Source

HUE-4492 [indexer] Rename test file to follow convention

Romain Rigaux 9 years ago
parent
commit
3955f47

+ 1 - 1
desktop/core/src/desktop/converters.py

@@ -68,7 +68,7 @@ class DocumentConverter(object):
             doc2.is_history = False
             doc2.is_history = False
 
 
           self.imported_docs.append(doc2)
           self.imported_docs.append(doc2)
-    except ImportError, e:
+    except ImportError:
       LOG.warn('Cannot convert Saved Query documents: beeswax app is not installed')
       LOG.warn('Cannot convert Saved Query documents: beeswax app is not installed')
 
 
     # Convert SQL Query history documents
     # Convert SQL Query history documents

+ 1 - 1
desktop/libs/indexer/src/indexer/smart_indexer.py

@@ -45,7 +45,7 @@ class Indexer(object):
     self.fs = fs
     self.fs = fs
     self.jt = jt
     self.jt = jt
     self.username = username
     self.username = username
-    self.user = User.objects.get(username=username)
+    self.user = User.objects.get(username=username) # To clean
 
 
   def _upload_workspace(self, morphline):
   def _upload_workspace(self, morphline):
     hdfs_workspace_path = Job.get_workspace(self.username)
     hdfs_workspace_path = Job.get_workspace(self.username)

+ 15 - 6
desktop/libs/indexer/src/indexer/tests_indexer.py → desktop/libs/indexer/src/indexer/smart_indexer_tests.py

@@ -13,12 +13,15 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # See the License for the specific language governing permissions and
 # limitations under the License.from nose.tools import assert_equal
 # limitations under the License.from nose.tools import assert_equal
+
 import StringIO
 import StringIO
 import logging
 import logging
 
 
 from nose.tools import assert_equal, assert_true
 from nose.tools import assert_equal, assert_true
 from nose.plugins.skip import SkipTest
 from nose.plugins.skip import SkipTest
 
 
+from desktop.lib.django_test_util import make_logged_in_client
+from desktop.lib.test_utils import grant_access, add_to_group
 from hadoop.pseudo_hdfs4 import is_live_cluster, shared_cluster
 from hadoop.pseudo_hdfs4 import is_live_cluster, shared_cluster
 
 
 from indexer.file_format import ApacheCombinedFormat, RubyLogFormat, HueLogFormat
 from indexer.file_format import ApacheCombinedFormat, RubyLogFormat, HueLogFormat
@@ -43,19 +46,20 @@ def _test_fixed_type_format_generate_morphline(format_):
   assert_true(isinstance(morphline, basestring))
   assert_true(isinstance(morphline, basestring))
 
 
 def _test_generate_field_operation_morphline(operation_format):
 def _test_generate_field_operation_morphline(operation_format):
-  fields = IndexerTest.simpleCSVFields[:]
+  fields = TestIndexer.simpleCSVFields[:]
   fields[0]['operations'].append(operation_format)
   fields[0]['operations'].append(operation_format)
 
 
   indexer = Indexer("test")
   indexer = Indexer("test")
   morphline =indexer.generate_morphline_config("test_collection", {
   morphline =indexer.generate_morphline_config("test_collection", {
       "columns": fields,
       "columns": fields,
-      "format": IndexerTest.simpleCSVFormat
+      "format": TestIndexer.simpleCSVFormat
     })
     })
 
 
   assert_true(isinstance(morphline, basestring))
   assert_true(isinstance(morphline, basestring))
 
 
 
 
-class IndexerTest():
+class TestIndexer():
+
   simpleCSVString = """id,Rating,Location,Name,Time
   simpleCSVString = """id,Rating,Location,Name,Time
 1,5,San Francisco,Good Restaurant,8:30pm
 1,5,San Francisco,Good Restaurant,8:30pm
 2,4,San Mateo,Cafe,11:30am
 2,4,San Mateo,Cafe,11:30am
@@ -106,8 +110,13 @@ class IndexerTest():
     'quoteChar': '"'
     'quoteChar': '"'
   }
   }
 
 
+  def setUp(self):
+    self.c = make_logged_in_client(is_superuser=False)
+    grant_access("test", "test", "indexer")
+    add_to_group("test")
+
   def test_guess_csv_format(self):
   def test_guess_csv_format(self):
-    stream = StringIO.StringIO(IndexerTest.simpleCSVString)
+    stream = StringIO.StringIO(TestIndexer.simpleCSVString)
     indexer = Indexer("test")
     indexer = Indexer("test")
 
 
     guessed_format = indexer.guess_format({'file': {"stream": stream, "name": "test.csv"}})
     guessed_format = indexer.guess_format({'file': {"stream": stream, "name": "test.csv"}})
@@ -127,7 +136,7 @@ class IndexerTest():
 
 
   def test_guess_format_invalid_csv_format(self):
   def test_guess_format_invalid_csv_format(self):
     indexer = Indexer("test")
     indexer = Indexer("test")
-    stream = StringIO.StringIO(IndexerTest.simpleCSVString)
+    stream = StringIO.StringIO(TestIndexer.simpleCSVString)
 
 
     guessed_format = indexer.guess_format({'file': {"stream": stream, "name": "test.csv"}})
     guessed_format = indexer.guess_format({'file': {"stream": stream, "name": "test.csv"}})
 
 
@@ -243,7 +252,7 @@ class IndexerTest():
     input_loc = "/tmp/test.csv"
     input_loc = "/tmp/test.csv"
 
 
     # upload the test file to hdfs
     # upload the test file to hdfs
-    fs.create(input_loc, data=IndexerTest.simpleCSVString, overwrite=True)
+    fs.create(input_loc, data=TestIndexer.simpleCSVString, overwrite=True)
 
 
     # open a filestream for the file on hdfs
     # open a filestream for the file on hdfs
     stream = fs.open(input_loc)
     stream = fs.open(input_loc)

+ 1 - 1
desktop/libs/notebook/src/notebook/api.py

@@ -320,7 +320,7 @@ def _save_notebook(notebook, user):
   notebook_doc.description = notebook_doc1.description = notebook['description']
   notebook_doc.description = notebook_doc1.description = notebook['description']
   notebook_doc.save()
   notebook_doc.save()
   notebook_doc1.save()
   notebook_doc1.save()
-  
+
   return notebook_doc, save_as
   return notebook_doc, save_as
 
 
 @require_POST
 @require_POST

+ 2 - 0
desktop/libs/notebook/src/notebook/models.py

@@ -76,6 +76,8 @@ def make_notebook(name='Browse', description='', editor_type='hive', statement='
       _update_property_value(sessions_properties, 'files', files)
       _update_property_value(sessions_properties, 'files', files)
   elif editor_type == 'java':
   elif editor_type == 'java':
     sessions_properties = [] # Java options
     sessions_properties = [] # Java options
+  else:
+    sessions_properties = []
 
 
   data = {
   data = {
     'name': name,
     'name': name,