Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bd15be9

Browse filesBrowse files
committed
unit test : move network (ftp, http) tests in specific unit.
1 parent f1fbecf commit bd15be9
Copy full SHA for bd15be9

3 files changed

+84-36Lines changed: 84 additions & 36 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/network_test.py‎

Copy file name to clipboard
+81Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# -*- coding: UTF-8 -*-
2+
#
3+
# Copyright (c) 2009-2010 Ars Aperta, Itaapy, Pierlis, Talend.
4+
#
5+
# Authors: Jerome Dumonteil <jerome.dumonteil@itaapy.com>
6+
#
7+
# This file is part of Lpod (see: http://lpod-project.org).
8+
# Lpod is free software; you can redistribute it and/or modify it under
9+
# the terms of either:
10+
#
11+
# a) the GNU General Public License as published by the Free Software
12+
# Foundation, either version 3 of the License, or (at your option)
13+
# any later version.
14+
# Lpod is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
# You should have received a copy of the GNU General Public License
19+
# along with Lpod. If not, see <http://www.gnu.org/licenses/>.
20+
#
21+
# b) the Apache License, Version 2.0 (the "License");
22+
# you may not use this file except in compliance with the License.
23+
# You may obtain a copy of the License at
24+
# http://www.apache.org/licenses/LICENSE-2.0
25+
#
26+
27+
# Import from the Standard Library
28+
import os
29+
from cStringIO import StringIO
30+
from ftplib import FTP
31+
from unittest import TestCase, main
32+
from urllib import urlopen
33+
34+
# Import from lpod
35+
from lpod.const import ODF_EXTENSIONS
36+
from lpod.container import odf_get_container
37+
38+
39+
# Tests requiring network moved from test_container and test_document
40+
class NetworkTest(TestCase):
41+
42+
def test_http_container(self):
43+
file = urlopen('http://ftp.lpod-project.org/example.odt')
44+
container = odf_get_container(file)
45+
mimetype = container.get_part('mimetype')
46+
self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
47+
48+
49+
def test_ftp_container(self):
50+
ftp = FTP('ftp.lpod-project.org')
51+
ftp.login()
52+
file = StringIO()
53+
ftp.retrbinary('RETR example.odt', file.write)
54+
ftp.quit()
55+
file.seek(0)
56+
container = odf_get_container(file)
57+
mimetype = container.get_part('mimetype')
58+
self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
59+
60+
61+
def test_http_document(self):
62+
file = urlopen('http://ftp.lpod-project.org/example.odt')
63+
document = odf_get_document(file)
64+
self.assertEqual(document.get_mimetype(), ODF_EXTENSIONS['odt'])
65+
66+
67+
def test_ftp_document(self):
68+
ftp = FTP('ftp.lpod-project.org')
69+
ftp.login()
70+
file = StringIO()
71+
ftp.retrbinary('RETR example.odt', file.write)
72+
ftp.quit()
73+
file.seek(0)
74+
document = odf_get_document(file)
75+
self.assertEqual(document.get_mimetype(), ODF_EXTENSIONS['odt'])
76+
77+
78+
79+
80+
if __name__ == '__main__':
81+
main()
Collapse file

‎test/test_container.py‎

Copy file name to clipboardExpand all lines: test/test_container.py
+1-19Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# Authors: Hervé Cauwelier <herve@itaapy.com>
66
# Luis Belmar-Letelier <luis@itaapy.com>
77
# David Versmisse <david.versmisse@itaapy.com>
8+
# Jerome Dumonteil <jerome.dumonteil@itaapy.com>
89
#
910
# This file is part of Lpod (see: http://lpod-project.org).
1011
# Lpod is free software; you can redistribute it and/or modify it under
@@ -121,25 +122,6 @@ def test_odf_xml(self):
121122
mimetype = container.get_part('mimetype')
122123
self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
123124

124-
# fixme : reactivate ftp
125-
#def test_http(self):
126-
# file = urlopen('http://ftp.lpod-project.org/example.odt')
127-
# container = odf_get_container(file)
128-
# mimetype = container.get_part('mimetype')
129-
# self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
130-
#
131-
#
132-
#def test_ftp(self):
133-
# ftp = FTP('ftp.lpod-project.org')
134-
# ftp.login()
135-
# file = StringIO()
136-
# ftp.retrbinary('RETR example.odt', file.write)
137-
# ftp.quit()
138-
# file.seek(0)
139-
# container = odf_get_container(file)
140-
# mimetype = container.get_part('mimetype')
141-
# self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
142-
143125

144126

145127
class ContainerTestCase(TestCase):
Collapse file

‎test/test_document.py‎

Copy file name to clipboardExpand all lines: test/test_document.py
+2-17Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Hervé Cauwelier <herve@itaapy.com>
77
# Luis Belmar-Letelier <luis@itaapy.com>
88
# David Versmisse <david.versmisse@itaapy.com>
9+
# Jerome Dumonteil <jerome.dumonteil@itaapy.com>
910
#
1011
# This file is part of Lpod (see: http://lpod-project.org).
1112
# Lpod is free software; you can redistribute it and/or modify it under
@@ -119,23 +120,7 @@ def test_odf_xml(self):
119120
self.assert_(odf_get_document(path))
120121

121122
#fixme : reactivitate ftp
122-
#def test_http(self):
123-
# file = urlopen('http://ftp.lpod-project.org/example.odt')
124-
# document = odf_get_document(file)
125-
# self.assertEqual(document.get_mimetype(), ODF_EXTENSIONS['odt'])
126-
#
127-
#
128-
#def test_ftp(self):
129-
# ftp = FTP('ftp.lpod-project.org')
130-
# ftp.login()
131-
# file = StringIO()
132-
# ftp.retrbinary('RETR example.odt', file.write)
133-
# ftp.quit()
134-
# file.seek(0)
135-
# document = odf_get_document(file)
136-
# self.assertEqual(document.get_mimetype(), ODF_EXTENSIONS['odt'])
137-
#
138-
#
123+
139124

140125
class DocumentTestCase(TestCase):
141126

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.