Skip to content

Commit 7a03064

Browse files
committed
Minor enhancements.
- Adjust documentation - Add Python 3.x support both source and supporting files - Adjust test cases - Add virtualenv support
1 parent 98ce005 commit 7a03064

File tree

10 files changed

+142
-103
lines changed

10 files changed

+142
-103
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.2.2 (2016.01.19)
2+
==================
3+
4+
* Adjust documentation
5+
* Add Python 3.x support
6+
17
0.2.1 (2015.12.20)
28
==================
39

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ install_devel_deps:
3838
pip install coverage mock
3939

4040
lint:clean
41-
flake8 --max-complexity 10
41+
flake8 --max-complexity 10 src/$(LIBRARY_NAME)/*.py
4242
pylint --rcfile=setup.cfg src/$(LIBRARY_NAME)/*.py
4343

4444
test:clean

README.rst

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,49 +23,35 @@ I will try to accomodate as much as I could as time permit. **There is no need t
2323

2424
If you are interested to contribute back to this project, please see **Contributing** section.
2525

26-
Example
27-
'''''''
28-
29-
+----------------+----------------------+---------------------------+-----------------+
30-
| Open Mailbox | host=imap.domain.com | [email protected] | password=secret |
31-
+----------------+----------------------+---------------------------+-----------------+
32-
| ${LATEST} = | Wait For Email | [email protected] | timeout=300 |
33-
+----------------+----------------------+---------------------------+-----------------+
34-
| ${HTML} = | Open Link From Email | ${LATEST} |
35-
+----------------+----------------------+---------------------------------------------+
36-
| Should Contain | ${HTML} | Your email address has been updated |
37-
+----------------+----------------------+---------------------------------------------+
38-
| Close Mailbox |
39-
+-------------------------------------------------------------------------------------+
40-
41-
Multipart Email Example
42-
'''''''''''''''''''''''
43-
44-
+----------------+----------------------+---------------------------+-----------------+
45-
| Open Mailbox | host=imap.domain.com | [email protected] | password=secret |
46-
+----------------+----------------------+---------------------------+-----------------+
47-
| ${LATEST} = | Wait For Email | [email protected] | timeout=300 |
48-
+----------------+----------------------+---------------------------+-----------------+
49-
| ${parts} = | Walk Multipart Email | ${LATEST} |
50-
+----------------+----------------------+---------------------------+-----------------+
51-
| :FOR | ${i} | IN RANGE | ${parts} |
52-
+----------------+----------------------+---------------------------+-----------------+
53-
| \\ | Walk Multipart Email | ${LATEST} |
54-
+----------------+----------------------+---------------------------------------------+
55-
| \\ | ${content-type} = | Get Multipart Content Type |
56-
+----------------+----------------------+---------------------------------------------+
57-
| \\ | Continue For Loop If | '${content-type}' != 'text/html' |
58-
+----------------+----------------------+---------------------------+-----------------+
59-
| \\ | ${payload} = | Get Multipart Payload | decode=True |
60-
+----------------+----------------------+---------------------------+-----------------+
61-
| \\ | Should Contain | ${payload} | your email |
62-
+----------------+----------------------+---------------------------+-----------------+
63-
| \\ | ${HTML} = | Open Link From Email | ${LATEST} |
64-
+----------------+----------------------+---------------------------+-----------------+
65-
| \\ | Should Contain | ${HTML} | Your email |
66-
+----------------+----------------------+---------------------------+-----------------+
67-
| Close Mailbox |
68-
+-------------------------------------------------------------------------------------+
26+
Examples
27+
''''''''
28+
29+
.. code:: robotframework
30+
31+
*** Settings ***
32+
Library ImapLibrary
33+
34+
*** Test Cases ***
35+
Email Verification
36+
Open Mailbox host=imap.domain.com [email protected] password=secret
37+
${LATEST} = Wait For Email [email protected] timeout=300
38+
${HTML} = Open Link From Email ${LATEST}
39+
Should Contain ${HTML} Your email address has been updated
40+
Close Mailbox
41+
42+
Multipart Email Verification
43+
Open Mailbox host=imap.domain.com [email protected] password=secret
44+
${LATEST} = Wait For Email [email protected] timeout=300
45+
${parts} = Walk Multipart Email ${LATEST}
46+
:FOR ${i} IN RANGE ${parts}
47+
\\ Walk Multipart Email ${LATEST}
48+
\\ ${content-type} = Get Multipart Content Type
49+
\\ Continue For Loop If '${content-type}' != 'text/html'
50+
\\ ${payload} = Get Multipart Payload decode=True
51+
\\ Should Contain ${payload} your email
52+
\\ ${HTML} = Open Link From Email ${LATEST}
53+
\\ Should Contain ${HTML} Your email
54+
Close Mailbox
6955
7056
Installation
7157
------------
@@ -75,15 +61,15 @@ Using ``pip``
7561

7662
The recommended installation method is using pip_:
7763

78-
.. code:: bash
64+
.. code:: console
7965
8066
pip install robotframework-imaplibrary
8167
8268
The main benefit of using ``pip`` is that it automatically installs all
8369
dependencies needed by the library. Other nice features are easy upgrading
8470
and support for un-installation:
8571

86-
.. code:: bash
72+
.. code:: console
8773
8874
pip install --upgrade robotframework-imaplibrary
8975
pip uninstall robotframework-imaplibrary
@@ -92,7 +78,7 @@ Notice that using ``--upgrade`` above updates both the library and all
9278
its dependencies to the latest version. If you want, you can also install
9379
a specific version:
9480

95-
.. code:: bash
81+
.. code:: console
9682
9783
pip install robotframework-imaplibrary==x.x.x
9884
@@ -128,23 +114,23 @@ and its dependencies yourself.
128114

129115
- Find each public key used to sign the package:
130116

131-
.. code:: bash
117+
.. code:: console
132118
133119
gpg --keyserver pgp.mit.edu --search-keys D1406DE7
134120
135121
- Select the number from the list to import the public key
136122

137123
- Verify the package against its PGP signature:
138124

139-
.. code:: bash
125+
.. code:: console
140126
141127
gpg --verify robotframework-imaplibrary-x.x.x.tar.gz.asc robotframework-imaplibrary-x.x.x.tar.gz
142128
143129
- Extract each source distribution to a temporary location.
144130

145131
- Go to each created directory from the command line and install each project using:
146132

147-
.. code:: bash
133+
.. code:: console
148134
149135
python setup.py install
150136
@@ -174,11 +160,10 @@ Usage
174160
To write tests with Robot Framework and ImapLibrary,
175161
ImapLibrary must be imported into your Robot test suite.
176162

177-
+-----------------------+
178-
| *** Settings *** |
179-
+---------+-------------+
180-
| Library | ImapLibrary |
181-
+---------+-------------+
163+
.. code:: robotframework
164+
165+
*** Settings ***
166+
Library ImapLibrary
182167
183168
See `Robot Framework User Guide`_ for more information.
184169

@@ -190,7 +175,7 @@ Building Keyword Documentation
190175

191176
The `Keyword Documentation`_ can be found online, if you need to generate the keyword documentation, run:
192177

193-
.. code:: bash
178+
.. code:: console
194179
195180
make doc
196181
@@ -199,7 +184,7 @@ Run Unit Tests, and Test Coverage Report
199184

200185
Test the testing library, talking about dogfooding, let's run:
201186

202-
.. code:: bash
187+
.. code:: console
203188
204189
make test
205190

analytics.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
IMAP Library - a IMAP email testing library.
2020
"""
2121

22-
from __future__ import print_function
2322
from os.path import split
2423
from re import sub
2524
import sys

doc/ImapLibrary.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ disable=locally-disabled
1111
[sdist]
1212
formats=gztar,zip
1313

14+
[TYPECHECK]
15+
ignored-modules=urllib2
16+
1417
[wheel]
1518
universal=1

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727

2828
LIBRARY_NAME = 'ImapLibrary'
2929
CWD = abspath(dirname(__file__))
30-
execfile(join(CWD, 'src', LIBRARY_NAME, 'version.py'))
30+
VERSION_PATH = join(CWD, 'src', LIBRARY_NAME, 'version.py')
31+
exec(compile(open(VERSION_PATH).read(), VERSION_PATH, 'exec'))
3132

3233
with codecs.open(join(CWD, 'README.rst'), encoding='utf-8') as reader:
3334
LONG_DESCRIPTION = reader.read()
@@ -47,10 +48,11 @@
4748
'Topic :: Software Development :: Testing',
4849
'License :: OSI Approved :: Apache Software License',
4950
'Programming Language :: Python :: 2.7',
51+
'Programming Language :: Python :: 3.5',
5052
],
5153
keywords='robot framework testing automation imap email mail softwaretesting',
5254
platforms='any',
5355
packages=find_packages('src'),
5456
package_dir={'': 'src'},
55-
install_requires=['robotframework >= 2.6.0']
57+
install_requires=['future', 'robotframework >= 2.6.0']
5658
)

src/ImapLibrary/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
IMAP Library - a IMAP email testing library.
2020
"""
2121

22+
from email import message_from_string
2223
from imaplib import IMAP4, IMAP4_SSL
23-
from ImapLibrary.version import get_version
2424
from re import findall
2525
from time import sleep, time
26-
import email
27-
import urllib2
26+
try:
27+
from urllib.request import urlopen
28+
except ImportError:
29+
from urllib2 import urlopen
30+
from builtins import str as ustr
31+
from ImapLibrary.version import get_version
2832

2933
__version__ = get_version()
3034

@@ -239,11 +243,11 @@ def open_link_from_email(self, email_index, link_index=0):
239243
urls = self.get_links_from_email(email_index)
240244

241245
if len(urls) > link_index:
242-
resp = urllib2.urlopen(urls[link_index])
246+
resp = urlopen(urls[link_index])
243247
content_type = resp.headers.getheader('content-type')
244248
if content_type:
245249
enc = content_type.split('charset=')[-1]
246-
return unicode(resp.read(), enc)
250+
return ustr(resp.read(), enc)
247251
else:
248252
return resp.read()
249253
else:
@@ -328,7 +332,7 @@ def walk_multipart_email(self, email_index):
328332
"""
329333
if not self._is_walking_multipart(email_index):
330334
data = self._imap.fetch(email_index, '(RFC822)')[1][0][1]
331-
msg = email.message_from_string(data)
335+
msg = message_from_string(data)
332336
self._start_multipart_walk(email_index, msg)
333337
try:
334338
self._part = next(self._mp_iter)

src/ImapLibrary/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
IMAP Library - a IMAP email testing library.
2020
"""
2121

22-
VERSION = '0.2.1'
22+
VERSION = '0.2.2'
2323

2424

2525
def get_version():

0 commit comments

Comments
 (0)