Exemple #1
0
    def test_set_id(self):
        sm = SnippetManager()

        snippet = sm.getSnippet(self.doc.getId())
        newId = "words"
        snippet.setId(newId)
        self.assertEqual(newId, snippet.getId())
Exemple #2
0
    def test_set_title(self):
        sm = SnippetManager()

        snippet = sm.getSnippet(self.doc.getId())
        newTitle = "words"
        snippet.setTitle(newTitle)
        self.assertEqual(newTitle, snippet.getTitle())
    def test_get_inv_snippet(self):
        sm = SnippetManager()

        try:
            snippet = sm.getSnippet('Junk')
        except LookupError:
            snippet = "exception"

        self.assertEqual(snippet, "exception")
Exemple #4
0
	def getContent(self):
		try:
			snippetId = self.request.form['form.widgets.id']
		except KeyError:
			snippetId = self.request.get('snippet-id')

		if snippetId is None:
			return False

		sm = SnippetManager()
		snippet = sm.getSnippet(snippetId)

		return snippet
Exemple #5
0
	def applyChanges(form, data):
		sm = SnippetManager()
		snippet = sm.getSnippet(data['id'])

		changes = {}
		for item in data:
			attribute = getattr(snippet, item)
			if item == 'text':
				#For whatever reason, tinyMCE loves using the \xc2\xa0 code
				data[item] = str(data[item]).replace('\xc2\xa0', ' ')

			if attribute == data[item]:
				continue
			else:
				changes[item] = data[item]

		sm.updateDoc(data['id'], changes)

		return changes
Exemple #6
0
	def getSnippetList(self, snippetList):
		sm = SnippetManager()

		out = []

		for snippet in snippetList:
			try:
				item = sm.getSnippet(snippet)

			except KeyError:
				#Getting here means the request snippetID doesn't exist
				#Setting the items "dead" tells the AJAX handler to remove the snippet tag,
				#if one exsists
				item = { 
					'id': snippet,
					'dead': True
				}

			out.append( item )

		return self.getSnippetAsJSON( out )
Exemple #7
0
    def test_set_text(self):
        sm = SnippetManager()

        snippet = sm.getSnippet(self.doc.getId())
        newText = " words words words"
        self.assertEqual(self.doc.getRawText(), snippet.getText())
Exemple #8
0
    def test_get_text(self):
        sm = SnippetManager()

        snippet = sm.getSnippet(self.doc.getId())
        self.assertEqual(self.doc.getRawText(), snippet.getText())
Exemple #9
0
    def test_get_title(self):
        sm = SnippetManager()

        snippet = sm.getSnippet(self.doc.getId())
        self.assertEqual(self.doc.Title(), snippet.getTitle())
    def test_get_snippet(self):
    	sm = SnippetManager()

    	snippet = sm.getSnippet('testDoc')
    	self.assertTrue(snippet.getId() == 'testDoc')