• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Group类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中treeio.core.models.Group的典型用法代码示例。如果您正苦于以下问题:Python Group类的具体用法?Python Group怎么用?Python Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Group类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_model_group

 def test_model_group(self):
     "Test Group model"
     obj = Group(name='test')
     obj.save()
     self.assertEquals('test', obj.name)
     self.assertNotEquals(obj.id, None)
     obj.delete()
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:7,代码来源:tests.py


示例2: setUp

 def setUp(self):
     "Initial Setup"
     
     if not self.prepared:
         Object.objects.all().delete()
         
         # Create objects
         try:
             self.group = Group.objects.get(name='test')
         except Group.DoesNotExist:
             Group.objects.all().delete()
             self.group = Group(name='test')
             self.group.save()
         
         try:
             self.user = DjangoUser.objects.get(username=self.username)
             self.user.set_password(self.password)
             try:
                 self.profile = self.user.get_profile()
             except Exception:
                 User.objects.all().delete()
                 self.user = DjangoUser(username=self.username, password='')
                 self.user.set_password(self.password)
                 self.user.save()
         except DjangoUser.DoesNotExist:
             User.objects.all().delete()
             self.user = DjangoUser(username=self.username, password='')
             self.user.set_password(self.password)
             self.user.save()
             
         try:
             perspective = Perspective.objects.get(name='default')
         except Perspective.DoesNotExist:
             Perspective.objects.all().delete()
             perspective = Perspective(name='default')
             perspective.set_default_user()
             perspective.save()
         ModuleSetting.set('default_perspective', perspective.id)
         
         self.perspective = Perspective(name='test')
         self.perspective.set_default_user()
         self.perspective.save()
         
         self.group = Group(name='test')
         self.group.save()
         
         self.client = Client()
         
         self.prepared = True
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:49,代码来源:tests.py


示例3: setUp

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            Object.objects.all().delete()

            # Create objects
            self.group, created = Group.objects.get_or_create(name='test')
            duser, created = DjangoUser.objects.get_or_create(username=self.username)
            duser.set_password(self.password)
            duser.save()
            self.user, created = User.objects.get_or_create(user=duser)
            self.user.save()
            perspective, created = Perspective.objects.get_or_create(name='default')
            perspective.set_default_user()
            perspective.save()
            ModuleSetting.set('default_perspective', perspective.id) 

            self.perspective = Perspective(name='test')
            self.perspective.set_default_user()
            self.perspective.save()

            self.group = Group(name='test')
            self.group.save()

            self.client = Client()

            self.prepared = True
开发者ID:3atmospheres,项目名称:treeio,代码行数:28,代码来源:tests.py


示例4: test_model_user

 def test_model_user(self):
     "Test User model"
     username = "test"
     password = "password"
     user = DjangoUser(username=username, password=password)
     user.set_password(password)
     user.save()
     self.assertEquals('test', user.username)
     self.assertNotEquals(user.id, None)
     group = Group(name='test')
     group.save()
     self.assertEquals('test', group.name)
     self.assertNotEquals(group.id, None)
     profile = User(user=user, default_group=group)
     profile.save()
     self.assertEquals(user, profile.user)
     self.assertNotEquals(profile.id, None)
     profile.delete()
     group.delete()
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:19,代码来源:tests.py


示例5: DocumentsViewsTest

class DocumentsViewsTest(TestCase):
    "Documents functional tests for views"

    username = "test"
    password = "password"
    prepared = False
    
    def setUp(self):
        "Initial Setup"
        
        if not self.prepared:
            Object.objects.all().delete()
            
            # Create objects
            
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()
            
            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()
                
            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
                
            ModuleSetting.set('default_perspective', perspective.id)
            
            self.folder = Folder(name='test')
            self.folder.set_default_user()
            self.folder.save()
            
            self.document = Document(title='test_document', folder=self.folder)
            self.document.set_default_user()
            self.document.save()
            
            self.file = File(name='test_file', folder=self.folder)
            self.file.set_default_user()
            self.file.save()
        
            self.link = WebLink(title='test', folder=self.folder, url='test')
            self.link.set_default_user()
            self.link.save()
                
            self.client = Client()
            
            self.prepared = True
    
    
    ######################################
    # Testing views when user is logged in
    ######################################   
    
    def test_index_login(self):
        "Test index page with login at /documents/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('document_index'))
        self.assertEquals(response.status_code, 200)   
        
    def test_index_documents_login(self):
        "Test index page with login at /documents/documents/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('index_documents'))
        self.assertEquals(response.status_code, 200)
        
    def test_index_files_login(self):
        "Test index page with login at /documents/files/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('index_files'))
        self.assertEquals(response.status_code, 200)
        
    def test_index_weblinks_login(self):
        "Test index page with login at /documents/weblinks/"
        response = self.client.post('/accounts/login',
#.........这里部分代码省略.........
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:101,代码来源:tests.py


示例6: FinanceAPITest

class FinanceAPITest(TestCase):

    "Finance api tests"
    username = "api_test"
    password = "api_password"
    prepared = False
    authentication_headers = {"CONTENT_TYPE": "application/json",
                              "HTTP_AUTHORIZATION": "Basic YXBpX3Rlc3Q6YXBpX3Bhc3N3b3Jk"}
    content_type = 'application/json'

    def setUp(self):
        "Initial Setup"
        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()
            User.objects.all().delete()

            # Create objects
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
            ModuleSetting.set('default_perspective', perspective.id)

            self.contact_type = ContactType(name='test')
            self.contact_type.set_default_user()
            self.contact_type.save()

            self.contact = Contact(name='test', contact_type=self.contact_type)
            self.contact.set_default_user()
            self.contact.save()

            self.category = Category(name='test')
            self.category.set_default_user()
            self.category.save()

            self.equity = Equity(
                issue_price=10, sell_price=10, issuer=self.contact, owner=self.contact)
            self.equity.set_default_user()
            self.equity.save()

            self.asset = Asset(name='test', owner=self.contact)
            self.asset.set_default_user()
            self.asset.save()

            self.tax = Tax(name='test', rate=10)
            self.tax.set_default_user()
            self.tax.save()

            self.currency = Currency(code="GBP",
                                     name="Pounds",
                                     symbol="L",
                                     is_default=True)
            self.currency.set_default_user()
            self.currency.save()

            self.account = Account(
                name='test', owner=self.contact, balance_currency=self.currency)
            self.account.set_default_user()
            self.account.save()

            self.liability = Liability(name='test',
                                       source=self.contact,
                                       target=self.contact,
                                       account=self.account,
                                       value=10,
                                       value_currency=self.currency)
            self.liability.set_default_user()
            self.liability.save()

            self.transaction = Transaction(name='test', account=self.account, source=self.contact,
                                           target=self.contact, value=10, value_currency=self.currency)
            self.transaction.set_default_user()
            self.transaction.save()
#.........这里部分代码省略.........
开发者ID:5n1p,项目名称:treeio,代码行数:101,代码来源:tests.py


示例7: ProjectsAPITest

class ProjectsAPITest(TestCase):

    "Projects functional tests for api"
    username = "api_test"
    password = "api_password"
    prepared = False
    authentication_headers = {"CONTENT_TYPE": "application/json",
                              "HTTP_AUTHORIZATION": "Basic YXBpX3Rlc3Q6YXBpX3Bhc3N3b3Jk"}
    content_type = 'application/json'

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()
            User.objects.all().delete()

            # Create objects

            try:
                self.group = Group.objects.get(name='api_test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='api_test')
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()

            ModuleSetting.set('default_perspective', perspective.id)

            self.contact_type = ContactType(name='api_test')
            self.contact_type.set_default_user()
            self.contact_type.save()

            self.contact = Contact(
                name='api_test', contact_type=self.contact_type)
            self.contact.set_default_user()
            self.contact.save()

            self.project = Project(
                name='api_test', manager=self.contact, client=self.contact)
            self.project.set_default_user()
            self.project.save()

            self.status = TaskStatus(name='api_test')
            self.status.set_default_user()
            self.status.save()

            self.milestone = Milestone(
                name='api_test', project=self.project, status=self.status)
            self.milestone.set_default_user()
            self.milestone.save()

            self.task = Task(
                name='api_test', project=self.project, status=self.status, priority=3)
            self.task.set_default_user()
            self.task.save()

            self.time_slot = TaskTimeSlot(
                task=self.task, details='api_test', time_from=datetime.now(), user=self.user.get_profile())
            self.time_slot.set_default_user()
            self.time_slot.save()

            self.parent = Project(name='api_test')
            self.parent.set_default_user()
            self.parent.save()

            self.parent_task = Task(
                name='api_test', project=self.project, status=self.status, priority=3)
            self.parent_task.set_default_user()
            self.parent_task.save()

            self.client = Client()

            self.prepared = True

    def test_unauthenticated_access(self):
#.........这里部分代码省略.........
开发者ID:AlexLX2,项目名称:treeio,代码行数:101,代码来源:tests.py


示例8: setUp

    def setUp(self):
        "Initial Setup"
        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()

            # Create objects
            try:
                self.group = Group.objects.get(name="test")
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name="test")
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password="")
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password="")
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name="default")
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name="default")
                perspective.set_default_user()
                perspective.save()
            ModuleSetting.set("default_perspective", perspective.id)

            self.type = ItemType(name="test")
            self.type.set_default_user()
            self.type.save()

            self.status = ItemStatus(name="test")
            self.status.set_default_user()
            self.status.save()

            self.field = ItemField(name="test", label="test", field_type="text")
            self.field.set_default_user()
            self.field.save()

            self.item = Item(name="test", item_type=self.type, status=self.status)
            self.item.set_default_user()
            self.item.save()

            self.value = ItemValue(field=self.field, item=self.item)
            self.value.save()

            self.servicing = ItemServicing(name="test")
            self.servicing.set_default_user()
            self.servicing.save()

            self.client = Client()

            self.prepared = True
开发者ID:nrazon,项目名称:treeio,代码行数:65,代码来源:tests.py


示例9: setUp

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()
            User.objects.all().delete()

            # Create objects
            try:
                self.group = Group.objects.get(name="test")
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name="test")
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password="")
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password="")
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name="default")
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name="default")
                perspective.set_user(self.user.get_profile())
                perspective.save()

            ModuleSetting.set("default_perspective", perspective.id)

            self.contact_type = ContactType(name="test")
            self.contact_type.set_default_user()
            self.contact_type.save()

            self.contact = Contact(name="test", contact_type=self.contact_type)
            self.contact.set_default_user()
            self.contact.save()

            self.status = TicketStatus(name="TestStatus")
            self.status.set_default_user()
            self.status.save()

            self.queue = TicketQueue(name="TestQueue", default_ticket_status=self.status)
            self.queue.set_default_user()
            self.queue.save()

            self.ticket = Ticket(name="TestTicket", status=self.status, queue=self.queue)
            self.ticket.set_default_user()
            self.ticket.save()

            self.agent = ServiceAgent(
                related_user=self.user.get_profile(), available_from=datetime.time(9), available_to=datetime.time(17)
            )
            self.agent.set_default_user()
            self.agent.save()

            self.service = Service(name="test")
            self.service.set_default_user()
            self.service.save()

            self.sla = ServiceLevelAgreement(
                name="test", service=self.service, client=self.contact, provider=self.contact
            )
            self.sla.set_default_user()
            self.sla.save()

            self.client = Client()

            self.prepared = True
开发者ID:hbcbh1999,项目名称:treeio,代码行数:81,代码来源:tests.py


示例10: MessagingApiTest

class MessagingApiTest(TestCase):
    "Messaging functional tests for api"

    username = "api_test"
    password = "api_password"
    prepared = False
    authentication_headers ={"CONTENT_TYPE": "application/json",
                             "HTTP_AUTHORIZATION" : "Basic YXBpX3Rlc3Q6YXBpX3Bhc3N3b3Jk" }
    content_type ='application/json'

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()

            # Create objects

            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
            ModuleSetting.set('default_perspective', perspective.id)

            self.contact_type = ContactType(name='test')
            self.contact_type.set_default_user()
            self.contact_type.save()

            self.contact = Contact(name='test', contact_type=self.contact_type)
            self.contact.set_default_user()
            self.contact.save()

            self.user_contact = Contact(name='test', related_user=self.user.get_profile(), contact_type=self.contact_type)
            self.user_contact.set_user(self.user)
            self.user_contact.save()

            self.stream = MessageStream(name='test')
            self.stream.set_default_user()
            self.stream.save()

            self.mlist = MailingList(name='test', from_contact=self.contact)
            self.mlist.set_default_user()
            self.mlist.save()

            self.message = Message(title='test', body='test', author=self.contact, stream=self.stream)
            self.message.set_default_user()
            self.message.save()

            self.client = Client()

            self.prepared = True

    def test_unauthenticated_access(self):
        "Test index page at /api/messaging/mlist"
        response = self.client.get('/api/messaging/mlist')
        # Redirects as unauthenticated
        self.assertEquals(response.status_code, 401)

    def test_get_mlist(self):
        """ Test index page api/messaging/mlist """
        response = self.client.get(path=reverse('api_messaging_mlist'), **self.authentication_headers)
        self.assertEquals(response.status_code, 200)

    def test_get_one_mlist(self):
        response = self.client.get(path=reverse('api_messaging_mlist', kwargs={'object_ptr': self.mlist.id}), **self.authentication_headers)
        self.assertEquals(response.status_code, 200)

    def test_update_mlist(self):
        updates = {"name": "API mailing list", "description": "API description update", "from_contact": self.contact.id,
                   "members": [self.contact.id,]}
        response = self.client.put(path=reverse('api_messaging_mlist', kwargs={'object_ptr': self.mlist.id}),
                                   content_type=self.content_type,  data=json.dumps(updates), **self.authentication_headers)
        self.assertEquals(response.status_code, 200)
#.........这里部分代码省略.........
开发者ID:3atmospheres,项目名称:treeio,代码行数:101,代码来源:tests.py


示例11: CoreViewsTest

class CoreViewsTest(TestCase):
    "Core View tests"
    username = "test"
    password = "password"
    prepared = False
    
    def setUp(self):
        "Initial Setup"
        
        if not self.prepared:
            Object.objects.all().delete()
            
            # Create objects
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()
            
            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()
                
            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
            ModuleSetting.set('default_perspective', perspective.id)
            
            self.perspective = Perspective(name='test')
            self.perspective.set_default_user()
            self.perspective.save()
            
            self.group = Group(name='test')
            self.group.save()
            
            self.client = Client()
            
            self.prepared = True


    ######################################
    # Testing views when user is logged in
    ###################################### 
    
    def test_home_login(self):
        "Test home page with login at /"
        response = self.client.post('/accounts/login', {'username': self.username, 
                                                        'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get('/')
        self.assertEquals(response.status_code, 200)
        
        
        
    # Perspectives
    
    def test_index_perspectives_login(self):
        "Test page with login at /admin/perspectives/"
        response = self.client.post('/accounts/login', {'username': self.username, 
                                                        'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('core_admin_index_perspectives'))
        self.assertEquals(response.status_code, 200)
  
    def test_perspective_add(self):
        "Test index page with login at /admin/perspective/add"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('core_admin_perspective_add'))
        self.assertEquals(response.status_code, 200)
              
    def test_perspective_view(self):
        "Test index page with login at /admin/perspective/view/<perspective_id>"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('core_admin_perspective_view', args=[self.perspective.id]))
        self.assertEquals(response.status_code, 200)
        
    def test_perspective_edit(self):
        "Test index page with login at /admin/perspective/edit/<perspective_id>"
        response = self.client.post('/accounts/login',
#.........这里部分代码省略.........
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:101,代码来源:tests.py


示例12: MiddlewareChatTest

class MiddlewareChatTest(TestCase):
    "Midleware chat tests"
    username = "test"
    password = "password"
    prepared = False

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            Object.objects.all().delete()

            # Create objects
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()

            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
            ModuleSetting.set('default_perspective', perspective.id)

            self.client = Client()

            self.prepared = True

    def test_chat_get_new_messages(self):
        "Test get_new_messages"
        response = self.client.post('/chat', {'json': '{"cmd":"Get", "location":"#"}'})
        self.assertEqual(response.status_code, 200)

    def test_chat_connect(self):
        "Test connect"
        response = self.client.post('/chat', {'json': '{"cmd":"Connect", "location":"#"}'})
        self.assertEqual(response.status_code, 200)

    def test_chat_disconnect(self):
        "Test disconnect"
        response = self.client.post('/chat', {'json': '{"cmd":"Disconnect", "location":"#"}'})
        self.assertEqual(response.status_code, 200)

    def test_chat_add_new_message(self):
        "Test add_new_message"
        response = self.client.post('/chat', {'json': '{"cmd":"Message","data":{"id":"test_b5e6d0470a5f4656c3bc77f879c3dbbc","text":"test message"},"location":"#"}'})
        self.assertEqual(response.status_code, 200)

    def test_chat_exit_from_conference(self):
        "Test exit_from_conference"
        response = self.client.post('/chat', {'json': '{"cmd":"Exit","data":{"id":"test_b5e6d0470a5f4656c3bc77f879c3dbbc"},"location":"#"}'})
        self.assertEqual(response.status_code, 200)

    def test_chat_add_users_in_conference(self):
        "Test add_users_in_conference"
        response = self.client.post('/chat', {'json': '{"cmd":"Add","data":{"id":"guest_006f721c4a59a44d969b9f73fb6360a5","users":["test"]},"location":"#"}'})
        self.assertEqual(response.status_code, 200)

    def test_chat_create_conference(self):
        "Test create_conference"
        response = self.client.post('/chat', {'json': '{"cmd":"Create","data":{"title":["Admin"],"users":["admin"]},"location":"#"}'})
        self.assertEqual(response.status_code, 200)
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:83,代码来源:tests.py


示例13: EventsViewsTest

class EventsViewsTest(TestCase):
    "Events functional tests for views"

    username = "test"
    password = "password"
    prepared = False
    
    def setUp(self):
        "Initial Setup"
        
        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()
    
            # Create objects
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()
            
            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()
                
            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
    
            ModuleSetting.set('default_perspective', perspective.id)
    
            self.event = Event(name='TestStatus', end=datetime.now())
            self.event.set_default_user()
            self.event.save()
            
            self.client = Client()
        
            self.prepared = True
    
    
    ######################################
    # Testing views when user is logged in
    ######################################  

    def test_index(self):
        "Test index page with login at /calendar/index"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('events_index'))
        self.assertEquals(response.status_code, 200)

    def test_upcoming(self):
        "Test index page with login at /calendar/upcoming"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('events_upcoming'))
        self.assertEquals(response.status_code, 200)
        
    def test_month(self):
        "Test index page with login at /calendar/month"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('events_month'))
        self.assertEquals(response.status_code, 200)

    def test_week(self):
        "Test index page with login at /calendar/week"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('events_week'))
        self.assertEquals(response.status_code, 200)

    def test_day(self):
        "Test index page with login at /calendar/day"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('events_day'))
        self.assertEquals(response.status_code, 200)
#.........这里部分代码省略.........
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:101,代码来源:tests.py


示例14: NewsViewsTest

class NewsViewsTest(TestCase):
    "Finance functional tests for views"

    username = "test"
    password = "password"
    prepared = False

    def setUp(self):
        "Initial Setup"
        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()
            User.objects.all().delete()
            
            # Create objects
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()
            
            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.profile = self.user.get_profile()
                except Exception:
                    User.objects.all().delete()
                    self.user = DjangoUser(username=self.username, password='')
                    self.user.set_password(self.password)
                    self.user.save()
            except DjangoUser.DoesNotExist:
                User.objects.all().delete()
                self.user = DjangoUser(username=self.username, password='')
                self.user.set_password(self.password)
                self.user.save()
                
            try:
                perspective = Perspective.objects.get(name='default')
            except Perspective.DoesNotExist:
                Perspective.objects.all().delete()
                perspective = Perspective(name='default')
                perspective.set_default_user()
                perspective.save()
            ModuleSetting.set('default_perspective', perspective.id)    
            
            self.client = Client()
            
            self.prepared = True


    ######################################
    # Testing views when user is logged in
    ###################################### 
            
    def test_news_index_login(self):
        "Test index page with login at /news/all/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('news_index'))
        self.assertEquals(response.status_code, 200) 
        
    def test_news_top(self):
        "Test index page with login at /news/top/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('news_top'))
        self.assertEquals(response.status_code, 200)
        
    def test_news_my_activity(self):
        "Test index page with login at /news/my/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('news_my_activity'))
        self.assertEquals(response.status_code, 200)

    def test_news_watchlist(self):
        "Test index page with login at /news/watchlist/"
        response = self.client.post('/accounts/login',
                                    {'username': self.username, 'password': self.password })
        self.assertRedirects(response, '/')
        response = self.client.get(reverse('news_my_watchlist'))
        self.assertEquals(response.status_code, 200)
        

    ######################################
    # Testing views when user is not logged in
    ###################################### 
    
    def test_news_index(self):
        "Testing /news/"
        response = self.client.get(reverse('news'))
        # Redirects as unauthenticated
        self.assertRedirects(response, "/accounts/login")
        
    def test_news_top_out(self):
#.........这里部分代码省略.........
开发者ID:KristianOellegaard,项目名称:treeio,代码行数:101,代码来源:tests.py


示例15: EventsViewsTest

class EventsViewsTest(TestCase):

    "Events functional tests for api"

    username = "api_test"
    password = "api_password"
    prepared = False
    authentication_headers = {"CONTENT_TYPE": "application/json",
                              "HTTP_AUTHORIZATION": "Basic YXBpX3Rlc3Q6YXBpX3Bhc3N3b3Jk"}
    content_type = 'application/json'

    def setUp(self):
        "Initial Setup"

        if not self.prepared:
            # Clean up first
            Object.objects.all().delete()

            # Create objects
            try:
                self.group = Group.objects.get(name='test')
            except Group.DoesNotExist:
                Group.objects.all().delete()
                self.group = Group(name='test')
                self.group.save()

            try:
                self.user = DjangoUser.objects.get(username=self.username)
                self.user.set_password(self.password)
                try:
                    self.p 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.ModuleSetting类代码示例发布时间:2022-05-27
下一篇:
Python utils.UrlQueryFilter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap