Example #1
0
    def test_user_info(self):
        from django.contrib.auth.models import User

        user = User(username="admin", email="admin@example.com")
        user.set_password("admin")
        user.save()

        self.assertRaises(Exception, self.client.get, reverse("sentry-raise-exc"))

        self.assertEquals(len(self.raven.events), 1)
        event = self.raven.events.pop(0)
        self.assertTrue("sentry.interfaces.User" in event)
        user_info = event["sentry.interfaces.User"]
        self.assertTrue("is_authenticated" in user_info)
        self.assertFalse(user_info["is_authenticated"])
        self.assertFalse("username" in user_info)
        self.assertFalse("email" in user_info)

        self.assertTrue(self.client.login(username="admin", password="admin"))

        self.assertRaises(Exception, self.client.get, reverse("sentry-raise-exc"))

        self.assertEquals(len(self.raven.events), 1)
        event = self.raven.events.pop(0)
        self.assertTrue("sentry.interfaces.User" in event)
        user_info = event["sentry.interfaces.User"]
        self.assertTrue("is_authenticated" in user_info)
        self.assertTrue(user_info["is_authenticated"])
        self.assertTrue("username" in user_info)
        self.assertEquals(user_info["username"], "admin")
        self.assertTrue("email" in user_info)
        self.assertEquals(user_info["email"], "admin@example.com")
Example #2
0
def install(request):
    """
    This view is a utility that makes sure that the objects that quanda
    needs on the db side are there. It should always check to see if the data
    is already there as the view can always be run after it's already been run.
    """

    if not request.user.is_staff:
        return HttpResponse("Unauthorized")

    # if a user named 'anonymous_user' does not exist, create it
    if not User.objects.filter(username="anonymous_user"):
        anonymous_user = User(username="anonymous_user")
        anonymous_user.save()

    # go through every ever and create a profile object if it doesn't already
    # exist. Also, give them each admin 10000 initial rep points
    for user in User.objects.all():
        profile = Profile.objects.get_or_create(user=user)[0]
        if user.is_staff:
            if profile.reputation < 1000:
                profile.reputation = 1000
                profile.save()

    return HttpResponse("done")
def import_user(u):
    user_info = u["u"]
    up_info = u["up"]

    # HACK to handle dates
    user_info["last_login"] = dateutil.parser.parse(user_info["last_login"])
    user_info["date_joined"] = dateutil.parser.parse(user_info["date_joined"])

    user_keys = [
        "id",
        "username",
        "email",
        "password",
        "is_staff",
        "is_active",
        "is_superuser",
        "last_login",
        "date_joined",
        "password",
    ]
    up_keys = ["language", "location", "meta", "name", "id", "user_id"]

    u = User()
    for key in user_keys:
        u.__setattr__(key, user_info[key])
    u.save()

    up = UserProfile()
    up.user = u
    for key in up_keys:
        up.__setattr__(key, up_info[key])
    up.save()
Example #4
0
class FeedTest(TestCase):
    fixtures = ["00_initial_data.json"]

    def setUp(self):
        self.client = Client()
        seconds = datetime.datetime.now().microsecond
        self.user = User(username="djtracker_feed%s" % seconds, email="djtracker@djtracker_feed.com")
        self.user.set_password("password")
        self.user.save()

    def test_personal_feed(self):
        response = self.client.get("/feeds/personal/%s/%s/" % (self.user.id, self.user.userprofile.uuid))

        self.assertEqual(response.status_code, 200)

    def test_project_feed(self):
        response = self.client.get("/feeds/project/1/")

        self.assertEqual(response.status_code, 200)

    def test_failed_personal_feed(self):
        response = self.client.get("/feeds/personal/%s/%s/" % (self.user.id, self.user.userprofile.uuid[0:-2]))

        self.assertEqual(response.status_code, 404)

    def test_failed_project_feed(self):
        response = self.client.get("/feeds/project/123414/")

        self.assertEqual(response.status_code, 404)
Example #5
0
    def setUp(self):
        self.u1 = User()
        self.u1.username = "user1"
        self.u1.first_name = "Justin"
        self.u1.last_name = "Gray"
        self.u1.set_password("test")

        self.u1.full_clean()
        self.u1.save()

        self.u2 = User()
        self.u2.username = "user2"
        self.u2.first_name = "Scott"
        self.u2.last_name = "Gray"
        self.u2.set_password("test")

        self.u2.full_clean()
        self.u2.save()

        self.u3 = User()
        self.u3.username = "user3"
        self.u3.first_name = "Joe"
        self.u3.last_name = "Mauro"

        self.u3.set_password("test")

        self.u3.full_clean()
        self.u3.save()
Example #6
0
File: forms.py Project: jacsice/hr
    def save(self):
        user = User(username=self.cleaned_data["username"], is_active=True)
        user.set_password(self.cleaned_data["pwd"])
        user.save()
        level = self._request.POST["level"]
        profile = UserProfile(user=user, name=self.cleaned_data["name"], level=level)
        profile.save()
        if level == "1":
            company = CompanyProfile.objects.get(id=self._request.POST.get("company_id"))
            company.profile = user.account
            company.save()

        data = u"user=%s, modify_table=UserProfile, action=添加, add_user_id=%d, add_user_name=%s" % (
            self._request.user.username,
            user.id,
            profile.name,
        )
        INFO_LOG.info(data)

        UserAction(
            user=self._request.user,
            ip=self._request.META["REMOTE_ADDR"],
            table_name="雇员信息表",
            modified_type=0,
            modified_id=user.id,
            action="添加",
        ).save()
class TestBasicsForm(WizardTestCase):

    wizard_class_slug = "import_wizard_view"
    url = "/dashboard/import/manual/"

    def setUp(self):
        self.eric = User(username="eric")
        self.eric.set_password("test")
        self.eric.save()
        self.client.login(username="eric", password="test")
        self.step_data["basics"] = {"name": "foobar", "repo": "http://example.com/foobar", "repo_type": "git"}

    def test_form_pass(self):
        """Only submit the basics"""
        resp = self.post_step("basics")
        self.assertWizardResponse(resp)

        proj = Project.objects.get(name="foobar")
        self.assertIsNotNone(proj)
        for (key, val) in self.step_data["basics"].items():
            self.assertEqual(getattr(proj, key), val)
        self.assertEqual(proj.documentation_type, "sphinx")

    def test_form_missing(self):
        """Submit form with missing data, expect to get failures"""
        self.step_data["basics"] = {"advanced": True}
        resp = self.post_step("basics")
        self.assertWizardFailure(resp, "name")
        self.assertWizardFailure(resp, "repo_type")
Example #8
0
 def test_edit_user_permissions(self):
     """Tests that users can't edit profiles other than their own"""
     user = User(username="jeff")
     user.save()
     r = self.c.get("%sedit/" % user.get_absolute_url())
     found = r.content.index("Oops!")
     self.failIfEqual(found, -1)
Example #9
0
    def setUp(self):
        user = User(username="lamer", email="lamer@from.ru")
        user.set_password("password")
        user.save()
        p = player(name="username", user=user)
        p.save()
        user = User(username="lamer1", email="lamer1@from.ru")
        user.set_password("password")
        user.save()
        p = player(name="username1", user=user)
        p.save()

        class request:
            user = User.objects.get(username="lamer")
            body = """{"x":1,"y":1}"""

        class request1:
            user = User.objects.get(username="lamer1")
            body = """{"x":1,"y":1}"""

        r = request()
        add_unit(r)
        r.body = """{"x":3,"y":4}"""
        add_unit(r)
        r = request1()
        add_unit(r)
Example #10
0
File: tests.py Project: Supy/sentry
    def member(self):
        user = User(username="member", email="member@localhost")
        user.set_password("member")
        user.save()

        TeamMember.objects.create(user=user, team=self.team, type=MEMBER_USER)
        return user
Example #11
0
File: tests.py Project: yrong/SWord
class WordSelectingTests(TestCase):
    def setUp(self):
        self.voc = Vocabulary(name="voc")
        self.voc.save()
        self.user = User(username="user", password="password")
        self.user.save()
        self.up = UserProfile(user=self.user, current_vocabulary=self.voc, daily_words_amount=35)
        self.up.save()
        f = file("scripts/vocabulary.txt", "r")

        for lno, line in enumerate(f):
            word, exp = line.strip().split(" ", 1)

            w = Word(content=word, description=exp)
            w.save()
            w.vocabulary = [self.voc]
            w.save()
            if lno >= 49:  # 只添加 50 个单词
                break

        f.close()

    def test_select_words(self):
        u"""单词随机选择测试"""
        words = select_word(self.user)
        words_set = list(words)
        self.assertEqual(len(words_set), self.up.daily_words_amount)

        for w in words_set:  # 将第一组单词添加到已掌握单词
            self.up.memorized_words.add(w)

        words = select_word(self.user)
        words_set = list(words)
        # 共 50 单词,已掌握 35 个,第二组只能选出 15 个
        self.assertEqual(len(words_set), 15)
 def add_student_to_db(self, request, student):
     """
     Adds a new user in the Database, along with the collected credentials from
     dionysos.teilar.gr
     """
     user = User(
         username=student.dionysos_username,
         first_name=unicode(student.dionysos_first_name),
         last_name=unicode(student.dionysos_last_name),
         email=unicode(student.dionysos_username) + u"@emptymail.com",
     )
     user.is_staff = False
     user.is_superuser = False
     try:
         user.save()
     except Exception as error:
         logger_syslog.error(error, extra=log_extra_data(request))
         logger_mail.exception(error)
         raise CronosError(u"Σφάλμα αποθήκευσης βασικών στοιχείων χρήστη")
     """
     Additional information are added in the userprofile table
     """
     try:
         user_profile = UserProfile(
             user=user,
             dionysos_username=student.dionysos_username,
             dionysos_password=encrypt_password(student.dionysos_password),
             registration_number=unicode(student.dionysos_registration_number),
             semester=unicode(student.dionysos_semester),
             school=student.dionysos_school,
             introduction_year=unicode(student.dionysos_introduction_year),
             declaration=student.dionysos_declaration,
             grades=student.dionysos_grades,
         )
         user_profile.save()
     except Exception as error:
         logger_syslog.error(error, extra=log_extra_data(request))
         logger_mail.exception(error)
         raise CronosError(u"Σφάλμα αποθήκευσης πρόσθετων στοιχείων χρήστη")
     """
     Everything went fine
     Log the new user and notify admins about the new registration
     """
     title = u"New user No.%s: %s" % (user.id, user.username)
     message = u"Name: %s %s\nDepartment: %s\nSemester: %s" % (
         user.first_name,
         user.last_name,
         user_profile.school,
         user_profile.semester,
     )
     logger_syslog.info(title, extra=log_extra_data(request))
     try:
         send_mail(settings.EMAIL_SUBJECT_PREFIX + title, message, settings.SERVER_EMAIL, get_admins_mails())
     except Exception as error:
         logger_syslog.error(error, extra=log_extra_data(request))
         logger_mail.exception(error)
     """
     Return the new user object
     """
     return user
Example #13
0
    def setUp(self):
        u = User(username="test", is_staff=True, is_active=True, is_superuser=True)
        u.set_password("test")
        u.save()
        self.login_user(u)

        self.test_data = {
            "title": u"RenderingTestCase-title",
            "slug": u"renderingtestcase-slug",
            "reverse_id": u"renderingtestcase-reverse-id",
            "text_main": u"RenderingTestCase-main",
            "text_sub": u"RenderingTestCase-sub",
        }
        self.test_data2 = {
            "title": u"RenderingTestCase-title2",
            "slug": u"RenderingTestCase-slug2",
            "reverse_id": u"renderingtestcase-reverse-id2",
        }
        self.test_data3 = {
            "title": u"RenderingTestCase-title3",
            "slug": u"RenderingTestCase-slug3",
            "reverse_id": u"renderingtestcase-reverse-id3",
            "text_sub": u"RenderingTestCase-sub3",
        }
        self.insert_test_content()
Example #14
0
    def save(self):
        "Creates the User and Member records with the field data and returns the user"
        if not self.is_valid():
            raise Exception("The form must be valid in order to save")

        first = self.cleaned_data["first_name"].strip().title()
        if len(first) == 0:
            raise forms.ValidationError("First Name Required.")
        last = self.cleaned_data["last_name"].strip().title()
        if len(last) == 0:
            raise forms.ValidationError("Last Name Required.")
        username = "%s_%s" % (first.lower(), last.lower())
        if User.objects.filter(username=username).count() > 0:
            raise forms.ValidationError("That username is already in use.")
        email = self.cleaned_data["email"].strip().lower()
        if len(email) == 0:
            raise forms.ValidationError("Email Required.")
        if User.objects.filter(email=email).count() > 0:
            raise forms.ValidationError("That email address is already in use.")

        user = User(username=username, first_name=first, last_name=last, email=email)
        user.save()
        member = user.get_profile()
        member.phone = self.cleaned_data["phone"].strip()
        member.save()

        return user
Example #15
0
    def create_dummy(first_name="", email=None, **kwargs):
        """ Creates a dummy user """
        # Generate a random string to use as a username. Keep it short
        # so that it doesn't overflow the username field!
        username = uuid.uuid4().hex[:16]

        if email is None:
            email = "%s@example.com" % username
        user = User(username=username, first_name=first_name, email=email)
        data = {"user": user}

        # If the caller of create_dummy passes in a user, then we won't use the
        # dummy user defined above
        data.update(kwargs)

        # Save the user after the update, so we don't save a new user if one
        # was never needed
        user = data["user"]
        user.save()
        person = user.get_profile()

        for key, value in data.items():
            setattr(person, key, value)
        person.save()

        return person
Example #16
0
 def navigate_to_profile(self):
     new_user = User(username=username, email=email)
     new_user.set_password(password)
     new_user.save()
     self.client.login(username=username, password=password)
     response = self.client.get(reverse("mealsOnWheels:profile"), follow=True)
     self.assertEqual(response.status_code, 200)
Example #17
0
 def setUp(self):
     self.user = User(username="test@email.com", email="test@email.com", password="p")
     self.user.save()
     self.user_no_related = User(username="test2@email.com", email="test2@email.com", password="p")
     self.user_no_related.save()
     self.presta = models.Prestataire(user=self.user)
     self.presta.save()
    def setUp(self):
        management.call_command("generate_sadiks", 1)
        management.call_command("generate_requestions", 25, distribute_in_any_sadik=True)

        self.kg = Sadik.objects.all()[0]
        self.operator = User(username=OPERATOR_USERNAME)
        self.operator.set_password(OPERATOR_PASSWORD)
        self.operator.save()
        Profile.objects.create(user=self.operator)
        operator_group = Group.objects.get(name=OPERATOR_GROUP_NAME)
        sadik_operator_group = Group.objects.get(name=SADIK_OPERATOR_GROUP_NAME)
        distributor_group = Group.objects.get(name=DISTRIBUTOR_GROUP_NAME)
        self.operator.groups = (operator_group, sadik_operator_group, distributor_group)
        self.supervisor = User(username=SUPERVISOR_USERNAME)
        self.supervisor.set_password(SUPERVISOR_PASSWORD)
        self.supervisor.save()
        Profile.objects.create(user=self.supervisor)
        supervisor_group = Group.objects.get(name=SUPERVISOR_GROUP_NAME)
        self.supervisor.groups = (supervisor_group,)

        self.requester = User(username=REQUESTER_USERNAME)
        self.requester.set_password(REQUESTER_PASSWORD)
        self.requester.save()
        permission = Permission.objects.get(codename=u"is_requester")
        self.requester.user_permissions.add(permission)
        Profile.objects.create(user=self.requester)
        self.requester.save()
        Preference.objects.create(key=PREFERENCE_IMPORT_FINISHED)
    def test_cut_calls_copy_then_cuts_and_remembers_some_stuff(self):
        clipboard = Clipboard()
        sheet = Sheet()
        user = User()
        user.username = "test_cuttter"
        user.save()
        sheet.owner = user
        clipboard.copy = Mock(wraps=clipboard.copy)

        worksheet = Worksheet()
        worksheet.A1.formula = "outside"
        worksheet.A2.formula = "inside"
        sheet.jsonify_worksheet(worksheet)
        sheet.save()

        clipboard.cut(sheet, (1, 2), (3, 4))

        self.assertCalledOnce(clipboard.copy, sheet, (1, 2), (3, 4))

        worksheet = sheet.unjsonify_worksheet()

        self.assertEquals(worksheet.A1.formula, "outside")
        self.assertEquals(worksheet.A2, Cell())

        self.assertEquals(clipboard.source_left, 1)
        self.assertEquals(clipboard.source_top, 2)
        self.assertEquals(clipboard.source_right, 3)
        self.assertEquals(clipboard.source_bottom, 4)

        self.assertEquals(clipboard.is_cut, True)
        self.assertEquals(clipboard.source_sheet, sheet)
Example #20
0
def create_default_admin():
    """Create the default user(s) for Pootle. You definitely want to change
    the admin account so that your default install is not accessible with the
    default credentials. The users 'noboby' and 'default' should be left as is."""
    admin = User(username=u"admin", first_name=u"Administrator", is_active=True, is_superuser=True, is_staff=True)
    admin.set_password("admin")
    admin.save()
Example #21
0
    def handle_label(self, label, **options):
        if not os.access(label, os.R_OK):
            raise CommandError("File '%s' is not readable." % label)

        if options["password"]:
            default_password = options["password"]
        else:
            default_password = None

        if _confirm(options["interactive"]) == "yes":
            print "Beginning import..."
            with open(label, "rb") as f:
                reader = unicode_csv_reader(f)
                try:
                    for row in reader:
                        print "Adding: %s" % ", ".join(row)
                        try:
                            user = User(username=row[0], first_name=row[1], last_name=row[2], email=row[3])
                            user.set_password(default_password)
                            user.save()
                        except IntegrityError:
                            print "Repeated user entry: %s" % ", ".join(row)
                            if options["skip_repeated"]:
                                print "Ignoring."
                            else:
                                sys.exit()

                except csv.Error as exception:
                    sys.exit("file %s, line %d: %s" % (label, reader.line_num, exception))
                else:
                    print "Finish."
        else:
            print "Cancelled."
Example #22
0
 def save(self):
     password = ""
     r = re.compile("sha1\$.*")
     if not r.match(self.password):
         password = self.password
         self.set_password(self.password)
     User.save(self)
Example #23
0
class CheckUtils(TestCase):
    fixtures = ["00_initial_data.json"]

    def setUp(self):
        seconds = datetime.datetime.now().microsecond
        self.user = User(username="djtracker_utils%s" % seconds, email="djtracker_utils@djtracker.com")
        self.user.save()
        self.project = models.Project.objects.get(id=1)
        self.project.allow_anon_comment = False
        self.project.allow_anon_viewing = False
        self.project.allow_anon_editing = False
        self.project.save()

    def test_check_permissions_false(self):
        can_comment = utils.check_permissions("comment", self.user, self.project)
        can_view = utils.check_permissions("view", self.user, self.project)
        can_edit = utils.check_permissions("edit", self.user, self.project)

        self.assertEqual(can_comment, False)
        self.assertEqual(can_view, False)
        self.assertEqual(can_edit, False)

    def test_check_permissions_true(self):
        self.project.allow_anon_comment = True
        self.project.allow_anon_viewing = True
        self.project.allow_anon_editing = True
        self.project.save()

        can_comment = utils.check_permissions("comment", self.user, self.project)
        can_view = utils.check_permissions("view", self.user, self.project)
        can_edit = utils.check_permissions("edit", self.user, self.project)

        self.assertEqual(can_comment, True)
        self.assertEqual(can_view, True)
        self.assertEqual(can_edit, True)
Example #24
0
    def test_awarding(self):
        """
    Tests that the fully committed badge is awarded to a user.
    """
        user = User(username="testuser", password="password")
        user.save()

        commitments = []
        # Create 5 test commitments.
        for i in range(0, 5):
            commitment = Commitment(title="Test commitment %i" % i, description="A commitment!", point_value=10)
            commitment.save()
            commitments.append(commitment)

        # Add the commitments one by one and see if the user earned a badge.
        # The badge should not be awarded until the very end.
        for index, commitment in enumerate(commitments):
            self.assertEqual(user.badges_earned.count(), 0, "Badge should not be awarded after %i commitments" % index)
            member = CommitmentMember(user=user, commitment=commitment, award_date=datetime.datetime.today())
            member.save()
            self.assertEqual(
                user.badges_earned.count(), 0, "Badge should not be awarded after commitment %i is awarded" % index
            )
            member.award_date = None
            member.save()

        self.assertEqual(user.badges_earned.count(), 1, "A badge should have been awarded.")
        self.assertEqual(
            user.badges_earned.all()[0].slug, "fully_committed", "Check that the Fully Committed badge was awarded."
        )
Example #25
0
 def test_sign(self):
     user = User(id="101", username="1", password="123")
     user.save()
     request_data = {"tn": "123", "subject": "subject", "body": "body", "total_fee": "500", "userid": "101"}
     response = self.client.post("/store/sign/", json.JSONEncoder().encode(request_data), "application/json")
     print(response.content)
     self.assertEqual(response.status_code, 200)
Example #26
0
    def setUp(self):
        user = User(username="tester", email="test@test.com")
        user.set_password("secret")
        user.save()

        self.c = Client()
        self.user = user
Example #27
0
    def test_user_info(self):
        user = User(username="admin", email="admin@example.com")
        user.set_password("admin")
        user.save()

        self.assertRaises(Exception, self.client.get, reverse("sentry-raise-exc"))

        self.assertEquals(len(self.raven.events), 1)
        event = self.raven.events.pop(0)
        self.assertTrue("user" in event["data"]["__sentry__"])
        user_info = event["data"]["__sentry__"]["user"]
        self.assertTrue("is_authenticated" in user_info)
        self.assertFalse(user_info["is_authenticated"])
        self.assertFalse("username" in user_info)
        self.assertFalse("email" in user_info)

        self.assertTrue(self.client.login(username="admin", password="admin"))

        self.assertRaises(Exception, self.client.get, reverse("sentry-raise-exc"))

        self.assertEquals(len(self.raven.events), 1)
        event = self.raven.events.pop(0)
        self.assertTrue("user" in event["data"]["__sentry__"])
        user_info = event["data"]["__sentry__"]["user"]
        self.assertTrue("is_authenticated" in user_info)
        self.assertTrue(user_info["is_authenticated"])
        self.assertTrue("username" in user_info)
        self.assertEquals(user_info["username"], "admin")
        self.assertTrue("email" in user_info)
        self.assertEquals(user_info["email"], "admin@example.com")
    def authenticate(self, linkedin_access_token, user=None):
        linkedin = LinkedIn(LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET)
        # get their profile

        profile = ProfileApi(linkedin).getMyProfile(access_token=linkedin_access_token)

        try:
            user_profile = LinkedInUserProfile.objects.get(linkedin_uid=profile.id)
            user = user_profile.user
            return user
        except LinkedInUserProfile.DoesNotExist:
            # Create a new user
            username = "LI:%s" % profile.id

            if not user:
                user = User(username=username)
                user.first_name, user.last_name = (profile.firstname, profile.lastname)
                user.email = "%s@socialauth" % (username)
                user.save()

            userprofile = LinkedInUserProfile(user=user, linkedin_uid=profile.id)
            userprofile.save()

            auth_meta = AuthMeta(user=user, provider="LinkedIn").save()
            return user
Example #29
0
class OrderListViewTestCase(TestCase):
    def setUp(self):
        self.user = User(username="test", is_active=True)
        self.user.set_password("test")
        self.user.save()
        self.order = Order.objects.create(user=self.user)

    def test_anonymous_user_redirected_to_login(self):
        url = reverse("order_list")
        response = self.client.get(url)
        self.assertEqual(response.status_code, 302)
        redirect_url = "%s?next=%s" % (settings.LOGIN_URL, url)
        self.assertTrue(redirect_url in response["location"])

    def test_authenticated_user_see_order_list(self):
        self.client.login(username="test", password="test")
        url = reverse("order_list")
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, unicode(self.order))

    def test_authenticated_user_see_order_detail(self):
        self.client.login(username="test", password="test")
        url = reverse("order_detail", kwargs={"pk": self.order.id})
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, unicode(self.order))
Example #30
0
class NewProjectTest(TestCase):
    fixtures = ["tests/fixtures/views.json"]

    def setUp(self):
        self.user = User(username="admin", email="admin@localhost", is_staff=True, is_superuser=True)
        self.user.set_password("admin")
        self.user.save()
        self.team = Team.objects.create(name="foo", slug="foo", owner=self.user)

    def test_new_project(self):
        path = reverse("sentry-new-team-project", args=[self.team.slug])

        self.client.login(username="admin", password="admin")

        # missing name
        resp = self.client.post(path)
        self.assertEquals(resp.status_code, 200)

        # valid params
        resp = self.client.post(path, {"name": "Test Project", "slug": "test"})
        self.assertNotEquals(resp.status_code, 200)

        project = Project.objects.filter(name="Test Project")
        self.assertTrue(project.exists())
        project = project.get()

        self.assertEquals(project.owner, self.user)
        self.assertNotEquals(project.team, None)

        member_set = list(project.team.member_set.all())

        self.assertEquals(len(member_set), 1)
        member = member_set[0]
        self.assertEquals(member.user, self.user)
        self.assertEquals(member.type, MEMBER_OWNER)