Repository navigation
Expand file tree
/
Copy pathwrite_tests.py
More file actions
83 lines (58 loc) · 2.24 KB
/
Copy pathwrite_tests.py
File metadata and controls
83 lines (58 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -*- coding: utf-8 -*-
import unittest
from assembla import API, Ticket, WikiPage
from assembla.tests.auth import auth
class TestAssembla(unittest.TestCase):
assembla = API(
key=auth[0],
secret=auth[1],
)
assembla.cache_responses = False
def __space_with_tickets(self, cutoff=1):
for space in self.assembla.spaces():
if len(space.tickets()) > cutoff:
return space
def test_update_ticket(self):
space = self.__space_with_tickets()
ticket = space.tickets()[0]
current_summary = ticket['summary']
new_summary = u"TEST"
ticket['summary'] = new_summary
ticket = ticket.write()
# fetch a copy, assert it has the summary we just pushed
ticket2 = space.tickets()[0]
self.assertEqual(ticket2['summary'], new_summary)
#put back the original summary
ticket2['summary'] = current_summary
ticket2.write()
def test_new_ticket(self):
space = self.__space_with_tickets()
ticket = Ticket({'summary': "Here is a new ticket"})
ticket.space = space
assert 'number' not in ticket.data
ticket = ticket.write()
# ticket now has a number
self.assertTrue(ticket['number'])
self.assertTrue(ticket['id'])
# tidy up (oh and test delete)
ticket.delete()
def _get_space_with_wiki_tools(self):
for space in self.assembla.spaces():
for tool in space.tools():
if 'wiki' in tool['menu_name'].lower():
return space
raise Exception('Can\'t find a space with the Wiki tool')
def test_wiki_page_write_and_delete(self):
space = self._get_space_with_wiki_tools()
page_name = 'Test_page'
wiki_page = WikiPage()
wiki_page.space = space
wiki_page['page_name'] = page_name
wiki_page['contents'] = 'Test content'
wiki_page = wiki_page.write()
self.assertTrue(wiki_page['id'])
self.assertTrue(len(space.wiki_pages(page_name=page_name)) > 0)
space.wiki_pages(page_name=page_name)[0].delete()
self.assertTrue(len(space.wiki_pages(page_name=page_name)) == 0)
if __name__ == '__main__':
unittest.main()