本文整理汇总了Python中treeio.core.models.Group.save方法的典型用法代码示例。如果您正苦于以下问题:Python Group.save方法的具体用法?Python Group.save怎么用?Python Group.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treeio.core.models.Group
的用法示例。
在下文中一共展示了Group.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_model_group
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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()
示例2: test_model_user
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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()
示例3: KnowledgeViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class KnowledgeViewsTest(TestCase):
"Knowledge functional tests for views"
username = "api_test"
password = "api_password"
prepared = False
authentication_headers ={"CONTENT_TYPE": "application/json",
"HTTP_AUTHORIZATION" : "Basic YXBpX3Rlc3Q6YXBpX3Bhc3N3b3Jk" }
content_type ='application/json'
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.folder = KnowledgeFolder(name='test', treepath='test')
self.folder.set_default_user()
self.folder.save()
self.category = KnowledgeCategory(name='test', treepath='test')
self.category.set_default_user()
self.category.save()
self.item = KnowledgeItem(name='test', folder=self.folder,
category=self.category, treepath='test')
self.item.set_default_user()
self.item.save()
# parent folder
self.parent = KnowledgeFolder(name='test', treepath='test')
self.parent.set_default_user()
self.parent.save()
self.client = Client()
self.prepared = True
def test_unauthenticated_access(self):
"Test index page at /api/knowledge/folders"
response = self.client.get('/api/knowledge/folders')
# Redirects as unauthenticated
self.assertEquals(response.status_code, 401)
def test_get_folders_list(self):
""" Test index page api/knowledge/folders """
response = self.client.get(path=reverse('api_knowledge_folders'), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_get_folder(self):
response = self.client.get(path=reverse('api_knowledge_folders', kwargs={'object_ptr': self.folder.id}), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_update_folder(self):
updates = {'name': 'Api folder update', 'parent': self.parent.id, 'details': '<p>api details</p>'}
response = self.client.put(path=reverse('api_knowledge_folders', kwargs={'object_ptr': self.folder.id}),
content_type=self.content_type, data=json.dumps(updates), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
data = json.loads(response.content)
self.assertEquals(updates["name"], data["name"])
self.assertEquals(updates["parent"], data["parent"]["id"])
self.assertEquals(updates["details"], data["details"])
def test_get_categories_list(self):
""" Test index page api/knowledge/categories """
#.........这里部分代码省略.........
示例4: SalesAPITest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class SalesAPITest(TestCase):
"Sales functional tests for views"
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()
self.contact_type.slug = 'machine'
self.contact_type.name = 'machine'
self.contact_type.save()
self.contact = Contact()
self.contact.contact_type = self.contact_type
self.contact.set_default_user()
self.contact.save()
self.assertNotEquals(self.contact.id, None)
self.status = SaleStatus()
self.status.active = True
self.status.use_sales = True
self.status.use_leads = True
self.status.use_opportunities = True
self.status.set_default_user()
self.status.save()
self.assertNotEquals(self.status.id, None)
self.currency = Currency(code="GBP",
name="Pounds",
symbol="L",
is_default=True)
self.currency.save()
self.source = SaleSource()
self.source.active = True
self.source.save()
self.source.set_user(self.user)
self.assertNotEquals(self.source.id, None)
self.product = Product(name="Test")
self.product.product_type = 'service'
self.product.active = True
self.product.sell_price = 10
self.product.buy_price = 100
self.product.set_default_user()
self.product.save()
self.assertNotEquals(self.product.id, None)
self.subscription = Subscription()
self.subscription.client = self.contact
self.subscription.set_default_user()
self.subscription.save()
self.assertNotEquals(self.subscription.id, None)
#.........这里部分代码省略.........
示例5: MessagingViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class MessagingViewsTest(TestCase):
"Messaging 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.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.stream = MessageStream(name='test')
self.stream.set_default_user()
self.stream.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
######################################
# Testing views when user is logged in
######################################
def test_message_index_login(self):
"Test index page with login at /messaging/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('messaging'))
self.assertEquals(response.status_code, 200)
def test_message_index_sent(self):
"Test index page with login at /messaging/sent/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('messaging_sent'))
self.assertEquals(response.status_code, 200)
def test_message_index_inbox(self):
"Test index page with login at /messaging/inbox/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('messaging_inbox'))
self.assertEquals(response.status_code, 200)
def test_message_index_unread(self):
"Test index page with login at /messaging/unread/"
response = self.client.post('/accounts/login',
#.........这里部分代码省略.........
示例6: ProjectsAPITest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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):
#.........这里部分代码省略.........
示例7: CoreAPITest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class CoreAPITest(TestCase):
"Core api tests"
username = "api_test"
password = "api_password"
prepared = False
authentication_headers ={"CONTENT_TYPE": "application/json",
"HTTP_AUTHORIZATION" : "Basic YXBpX3Rlc3Q6YXBpX3Bhc3N3b3Jk" }
content_type ='application/json'
prepared = False
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
def test_unauthenticated_access(self):
"Test index page at /admin/api/users"
response = self.client.get('/admin/api/users')
# Redirects as unauthenticated
self.assertEquals(response.status_code, 404)
def test_get_ticket_groups_list(self):
""" Test index page api /admin/api/groups """
response = self.client.get(path=reverse('api_admin_groups'), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_get_group(self):
response = self.client.get(path=reverse('api_admin_groups', kwargs={'accessentity_ptr': self.group.id}), **self.authentication_headers)
print response.content
self.assertEquals(response.status_code, 200)
def test_update_group(self):
updates = {'name': 'Api group name', 'details': '<p>api details</p>', 'perspective': self.perspective.id}
response = self.client.put(path=reverse('api_admin_groups', kwargs={'accessentity_ptr': self.group.id}),
content_type=self.content_type, data=json.dumps(updates), **self.authentication_headers)
print response.content
self.assertEquals(response.status_code, 200)
data = json.loads(response.content)
self.assertEquals(data['name'], updates['name'])
self.assertEquals(data['details'], updates['details'])
self.assertEquals(data['perspective']['id'], updates['perspective'])
def test_get_ticket_users_list(self):
""" Test index page api /admin/api/users """
response = self.client.get(path=reverse('api_admin_users'), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_get_user(self):
response = self.client.get(path=reverse('api_admin_users', kwargs={'accessentity_ptr': self.user.id}), **self.authentication_headers)
print response.content
self.assertEquals(response.status_code, 200)
def test_update_user(self):
updates = {'name': 'Api user name', 'default_group': self.group.id, 'disabled': False,
'perspective': self.perspective.id}
response = self.client.put(path=reverse('api_admin_users', kwargs={'accessentity_ptr': self.user.id}),
content_type=self.content_type, data=json.dumps(updates), **self.authentication_headers)
self.assertEquals(response.status_code, 405)
#data = json.loads(response.content)
#self.assertEquals(data['name'], updates['name'])
#self.assertEquals(data['disabled'], updates['disabled'])
#self.assertEquals(data['default_group']['id'], updates['default_group'])
#self.assertEquals(data['perspective']['id'], updates['perspective'])
def test_delete_self(self):
response = self.client.delete(path=reverse('api_admin_users', kwargs={'accessentity_ptr': self.user.id}), **self.authentication_headers)
self.assertEquals(response.status_code, 401)
def test_get_ticket_modules_list(self):
""" Test index page api /admin/api/modules """
response = self.client.get(path=reverse('api_admin_modules'), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
#.........这里部分代码省略.........
示例8: ServicesViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class ServicesViewsTest(TestCase):
"Services 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"
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_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
def test_unauthenticated_access(self):
"Test index page at /api/services/services"
response = self.client.get("/api/services/services")
# Redirects as unauthenticated
#.........这里部分代码省略.........
示例9: EventsViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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.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
def test_unauthenticated_access(self):
"Test index page at /api/calendar/events"
response = self.client.get('/api/calendar/events')
# Redirects as unauthenticated
self.assertEquals(response.status_code, 401)
def test_get_events_list(self):
""" Test index page api/infrastructure/types """
response = self.client.get(
path=reverse('api_events'), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_get_field(self):
response = self.client.get(path=reverse(
'api_events', kwargs={'object_ptr': self.event.id}), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_update_field(self):
updates = {"name": "Api_name", "details": "Api details",
"start": "2011-03-01 01:12:09", "end": "2011-03-09 13:05:09"}
response = self.client.put(path=reverse('api_events', kwargs={'object_ptr': self.event.id}),
content_type=self.content_type, data=json.dumps(updates), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
data = json.loads(response.content)
self.assertEquals(data['name'], updates['name'])
self.assertEquals(data['details'], updates['details'])
self.assertEquals(data['start'], updates['start'])
self.assertEquals(data['end'], updates['end'])
示例10: EventsViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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)
#.........这里部分代码省略.........
示例11: NewsViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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):
#.........这里部分代码省略.........
示例12: DocumentsViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
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',
#.........这里部分代码省略.........
示例13: ReportsViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class ReportsViewsTest(TestCase):
"Reports 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.report = Report(name='test')
self.report.set_default_user()
self.report.save()
self.chart = Chart(name='test_chart', report=self.report)
self.chart.set_default_user()
self.chart.save()
self.client = Client()
self.prepared = True
######################################
# Testing views when user is logged in
######################################
def test_reports_login(self):
"Testing /reports/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports'))
self.assertEquals(response.status_code, 200)
def test_index_login(self):
"Testing /reports/index/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_index'))
self.assertEquals(response.status_code, 200)
def test_index_owned(self):
"Testing /reports/owned/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_index'))
self.assertEquals(response.status_code, 200)
# Charts
def test_chart_add(self):
"Testing /reports/chart/add/"
response = self.client.post('/accounts/login',
{'username': self.username, 'password': self.password })
self.assertRedirects(response, '/')
response = self.client.get(reverse('reports_chart_add'))
self.assertEquals(response.status_code, 200)
#.........这里部分代码省略.........
示例14: FinanceViewsTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class FinanceViewsTest(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.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()
self.client = Client()
self.prepared = True
#.........这里部分代码省略.........
示例15: InfrastructureApiTest
# 需要导入模块: from treeio.core.models import Group [as 别名]
# 或者: from treeio.core.models.Group import save [as 别名]
class InfrastructureApiTest(TestCase):
"Infrastructure 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.field = ItemField(
name='test', label='test', field_type='text')
self.field.set_default_user()
self.field.save()
self.type = ItemType(name='test')
self.type.set_default_user()
self.type.save()
self.type.fields.add(self.field)
self.status = ItemStatus(name='test')
self.status.set_default_user()
self.status.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
def test_unauthenticated_access(self):
"Test index page at /api/infrastructure/types"
response = self.client.get('/api/infrastructure/types')
# Redirects as unauthenticated
self.assertEquals(response.status_code, 401)
def test_get_fields_list(self):
""" Test index page api/infrastructure/types """
response = self.client.get(
path=reverse('api_infrastructure_fields'), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_get_field(self):
response = self.client.get(path=reverse('api_infrastructure_fields', kwargs={
'object_ptr': self.field.id}), **self.authentication_headers)
self.assertEquals(response.status_code, 200)
def test_update_field(self):
updates = {"name": "Api_name", "label": "Api label", "field_type": "text",
"required": True, "details": "Api details"}
#.........这里部分代码省略.........