Skip to content

Commit d361ac5

Browse files
committed
Merge pull request #8 from oscarmcm/master
better exceptions, remove unused packages
2 parents ea75755 + 79e1333 commit d361ac5

11 files changed

Lines changed: 32 additions & 34 deletions

.coverage

802 Bytes
Binary file not shown.

magicembed/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# -*- coding: utf-8 -*-
2-
__version__ = '1.0.1' # pragma: no cover
2+
__version__ = '1.0.2' # pragma: no cover

magicembed/providers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from urlparse import parse_qs
77

8+
from django.core.exceptions import ImproperlyConfigured
89
from django.conf import settings
910

10-
1111
class Provider(object):
1212

1313
def __init__(self, url, size=(640, 480)):
@@ -65,7 +65,7 @@ def __init__(self, url, size=(640, 480)):
6565
if key is not None:
6666
self.api_url = 'http://api.embed.ly/1/oembed?key=%s&url=%s&maxwidth=%s&format=json' % (key, url, size[0])
6767
else:
68-
raise ValueError("If you want to use this please set the Embedly api key")
68+
raise ImproperlyConfigured("If you want to use this please set the Embedly api key")
6969

7070
def render_video(self):
7171
return self._call_api()['html']
@@ -76,8 +76,8 @@ def render_thumbnail(self):
7676
def _call_api(self):
7777
try:
7878
data = json.loads(urllib.urlopen(self.api_url).read())
79-
except IOError:
80-
raise IOError("Please set the Embedly api key correctly")
79+
except ImproperlyConfigured:
80+
raise ImproperlyConfigured("Please set the Embedly api key correctly")
8181
return data
8282

8383

137 Bytes
Loading

magicembed/tests/coverage/errors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<body>
4545

4646
<div id="content-header">
47-
<h1>Test Coverage Report: error packages and modules</h1><p>Generated: Wed 2015-08-05 13:23 CST</p></div>
47+
<h1>Test Coverage Report: error packages and modules</h1><p>Generated: Wed 2015-08-05 15:26 CST</p></div>
4848
<div id="result-list">
4949
<p> <code>django_coverage.utils.module_tools.find_or_load_module</code> had
5050
problems importing these packages and modules:

magicembed/tests/coverage/excludes.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<body>
4545

4646
<div id="content-header">
47-
<h1>Test Coverage Report: excluded packages and modules</h1><p>Generated: Wed 2015-08-05 13:23 CST</p></div>
47+
<h1>Test Coverage Report: excluded packages and modules</h1><p>Generated: Wed 2015-08-05 15:26 CST</p></div>
4848
<div id="result-list">
4949
<p> These packages and modules were excluded from the coverage analysis in
5050
<code>django.conf.settings.COVERAGE_MODULE_EXCLUDES</code> or they do

magicembed/tests/coverage/index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
<div id="content-header">
118118
<h1>Test Coverage Report</h1>
119-
<p>Generated: Wed 2015-08-05 13:23 CST</p>
119+
<p>Generated: Wed 2015-08-05 15:26 CST</p>
120120
<p><img src="coverage_status.png"></p>
121121
</div>
122122

@@ -138,10 +138,10 @@ <h1>Test Coverage Report</h1>
138138
<tfoot>
139139
<tr>
140140
<td class="module-name">Total</td>
141-
<td>71</td>
142-
<td>48</td>
143-
<td>9</td>
144-
<td>77.4%</td>
141+
<td>72</td>
142+
<td>47</td>
143+
<td>10</td>
144+
<td>75.8%</td>
145145
</tr>
146146
</tfoot>
147147
<tbody>
@@ -155,10 +155,10 @@ <h1>Test Coverage Report</h1>
155155

156156
<tr>
157157
<td class="module-name"><a href="modules/magicembed.providers.html">magicembed.providers</a></td>
158-
<td>58</td>
159-
<td>48</td>
160-
<td>5</td>
161-
<td class="normal">90.6%</td>
158+
<td>59</td>
159+
<td>47</td>
160+
<td>6</td>
161+
<td class="normal">88.7%</td>
162162
</tr>
163163

164164
<tr>

magicembed/tests/coverage/modules/magicembed.__init__.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h1>
129129
1 total statements,
130130
<span class="normal">100.0% covered</span>
131131
</h1>
132-
<p>Generated: Wed 2015-08-05 13:23 CST</p>
132+
<p>Generated: Wed 2015-08-05 15:26 CST</p>
133133
<p>Source file: /Users/oscarmcm/Code/Django/django-magicembed/magicembed/__init__.py</p>
134134
<p>
135135
Stats:
@@ -143,7 +143,7 @@ <h1>
143143
<div id="source-listing">
144144
<ol>
145145
<li class="ignored"><code># -*- coding: utf-8 -*-</code></li>
146-
<li class="excluded"><code>__version__ = '1.0.0' # pragma: no cover</code></li>
146+
<li class="excluded"><code>__version__ = '1.0.2' # pragma: no cover</code></li>
147147
</ol>
148148
</div>
149149

magicembed/tests/coverage/modules/magicembed.providers.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@
127127
<div id="content-header">
128128
<h1>
129129
<span id="module-name">magicembed.providers</span>:
130-
58 total statements,
131-
<span class="normal">90.6% covered</span>
130+
59 total statements,
131+
<span class="normal">88.7% covered</span>
132132
</h1>
133-
<p>Generated: Wed 2015-08-05 13:23 CST</p>
133+
<p>Generated: Wed 2015-08-05 15:26 CST</p>
134134
<p>Source file: /Users/oscarmcm/Code/Django/django-magicembed/magicembed/providers.py</p>
135135
<p>
136136
Stats:
137-
<span class="executed">48 executed</span>,
138-
<span class="missed">5 missed</span>,
139-
<span class="excluded">5 excluded</span>,
140-
<span class="ignored">33 ignored</span>
137+
<span class="executed">47 executed</span>,
138+
<span class="missed">6 missed</span>,
139+
<span class="excluded">6 excluded</span>,
140+
<span class="ignored">32 ignored</span>
141141
</p>
142142
</div>
143143

@@ -150,9 +150,9 @@ <h1>
150150
<li class="ignored"><code></code></li>
151151
<li class="excluded"><code>from urlparse import parse_qs</code></li>
152152
<li class="ignored"><code></code></li>
153+
<li class="excluded"><code>from django.core.exceptions import ImproperlyConfigured</code></li>
153154
<li class="excluded"><code>from django.conf import settings</code></li>
154155
<li class="ignored"><code></code></li>
155-
<li class="ignored"><code></code></li>
156156
<li class="executed"><code>class Provider(object):</code></li>
157157
<li class="ignored"><code></code></li>
158158
<li class="executed"><code> def __init__(self, url, size=(640, 480)):</code></li>
@@ -210,20 +210,20 @@ <h1>
210210
<li class="executed"><code> if key is not None:</code></li>
211211
<li class="executed"><code> self.api_url = 'http://api.embed.ly/1/oembed?key=%s&amp;url=%s&amp;maxwidth=%s&amp;format=json' % (key, url, size[0])</code></li>
212212
<li class="ignored"><code> else:</code></li>
213-
<li class="missed"><code> raise ValueError("If you want to use this please set the Embedly api key")</code></li>
213+
<li class="missed"><code> raise ImproperlyConfigured("If you want to use this please set the Embedly api key")</code></li>
214214
<li class="ignored"><code></code></li>
215215
<li class="executed"><code> def render_video(self):</code></li>
216216
<li class="executed"><code> return self._call_api()['html']</code></li>
217217
<li class="ignored"><code></code></li>
218218
<li class="executed"><code> def render_thumbnail(self):</code></li>
219-
<li class="executed"><code> return self._call_api()['thumbnail_url']</code></li>
219+
<li class="missed"><code> return self._call_api()['thumbnail_url']</code></li>
220220
<li class="ignored"><code></code></li>
221221
<li class="executed"><code> def _call_api(self):</code></li>
222222
<li class="executed"><code> try:</code></li>
223223
<li class="executed"><code> data = json.loads(urllib.urlopen(self.api_url).read())</code></li>
224-
<li class="missed"><code> except IOError:</code></li>
225-
<li class="missed"><code> raise IOError("Please set the Embedly api key correctly")</code></li>
226-
<li class="executed"><code> return data</code></li>
224+
<li class="executed"><code> except ImproperlyConfigured:</code></li>
225+
<li class="missed"><code> raise ImproperlyConfigured("Please set the Embedly api key correctly")</code></li>
226+
<li class="missed"><code> return data</code></li>
227227
<li class="ignored"><code></code></li>
228228
<li class="ignored"><code></code></li>
229229
<li class="executed"><code>def get_provider(url, size=None):</code></li>

magicembed/tests/coverage/modules/magicembed.templatetags.magicembed_tags.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h1>
129129
12 total statements,
130130
<span class="critical">0.0% covered</span>
131131
</h1>
132-
<p>Generated: Wed 2015-08-05 13:23 CST</p>
132+
<p>Generated: Wed 2015-08-05 15:26 CST</p>
133133
<p>Source file: /Users/oscarmcm/Code/Django/django-magicembed/magicembed/templatetags/magicembed_tags.py</p>
134134
<p>
135135
Stats:

0 commit comments

Comments
 (0)