浏览代码

HUE-867 [desktop] Fix fast tests

- Ensuring home directory breaks first login tests
abec 13 年之前
父节点
当前提交
429100d
共有 2 个文件被更改,包括 48 次插入15 次删除
  1. 20 15
      desktop/core/src/desktop/auth/views_test.py
  2. 28 0
      desktop/libs/hadoop/src/hadoop/test_base.py

+ 20 - 15
desktop/core/src/desktop/auth/views_test.py

@@ -16,30 +16,35 @@
 # limitations under the License.
 
 from nose.tools import assert_true, assert_false, assert_equal
+from nose.plugins.attrib import attr
 
 from django.contrib.auth.models import User
 from django.test.client import Client
 from desktop.lib.django_test_util import make_logged_in_client
+from hadoop.test_base import PseudoHdfsTestBase
 
-def test_jframe_login():
-  # Simulate first login ever
-  for user in User.objects.all():
-    user.delete()
 
-  c = Client()
+class TestLogin(PseudoHdfsTestBase):
+  def test_jframe_login(self):
+    # Simulate first login ever
+    for user in User.objects.all():
+      user.delete()
 
-  response = c.get('/accounts/login/')
-  assert_equal(200, response.status_code, "Expected ok status.")
-  assert_true(response.context['first_login_ever'])
+    c = Client()
 
-  response = c.post('/accounts/login/',
-                    dict(username="foo",
-                         password="foo"))
-  assert_equal(302, response.status_code, "Expected ok redirect status.")
+    response = c.get('/accounts/login/')
+    assert_equal(200, response.status_code, "Expected ok status.")
+    assert_true(response.context['first_login_ever'])
 
-  response = c.get('/accounts/login/')
-  assert_equal(200, response.status_code, "Expected ok status.")
-  assert_false(response.context['first_login_ever'])
+    response = c.post('/accounts/login/',
+                      dict(username="foo",
+                           password="foo"))
+    assert_equal(302, response.status_code, "Expected ok redirect status.")
+    assert_true(self.fs.exists("/user/foo"))
+
+    response = c.get('/accounts/login/')
+    assert_equal(200, response.status_code, "Expected ok status.")
+    assert_false(response.context['first_login_ever'])
 
 
 def test_non_jframe_login():

+ 28 - 0
desktop/libs/hadoop/src/hadoop/test_base.py

@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+from hadoop import pseudo_hdfs4
+
+
+class PseudoHdfsTestBase(object):
+  requires_hadoop = True
+
+  @classmethod
+  def setup_class(cls):
+    cls.cluster = pseudo_hdfs4.shared_cluster()
+    cls.fs = cls.cluster.fs