-
Notifications
You must be signed in to change notification settings - Fork 5
/
test_debug_addons_api.py
68 lines (53 loc) · 2.47 KB
/
test_debug_addons_api.py
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
#!/usr/bin/env python
from addons_api import AddOnsAPI
from unittestzero import Assert
import pytest
#These tests should only call the api. There should be no tests requiring selenium in this class.
class TestAPIOnlyTests():
@pytest.mark.skip_selenium
def test_get_addon_type_name(self, testsetup):
addons_xml = AddOnsAPI(testsetup)
Assert.equal("Extension", addons_xml.get_addon_type_name("Firebug"))#("Firefox 3 theme for Firefox 4"))
@pytest.mark.skip_selenium
def test_get_version_number(self, testsetup):
addons_xml = AddOnsAPI(testsetup)
Assert.equal("1.1.6", addons_xml.get_addon_version_number("Illuminations for Developers for Firebug"))
@pytest.mark.skip_selenium
def test_addon_is_not_in_search_results(self, testsetup):
addons_xml = AddOnsAPI(testsetup)
Assert.raises(AttributeError, addons_xml.get_xml_for_single_addon("Firepug"))
@pytest.mark.skip_selenium
def test_first_addon_fails_when_addon_is_not_in_results(self, testsetup):
addons_xml = AddOnsAPI(testsetup)
bad_xml = AddOnsAPI("Firepug")
#try:
Assert.raises (AttributeError, addons_xml )#self.bad_xml.get_name_of_first_addon())
#except AssertionError:
#pass
@pytest.mark.skip_selenium
def test_that_assert_raises_catches_exceptions(self):
Assert.raises(ZeroDivisionError, self._divide_by_zero)
@pytest.mark.skip_selenium
def test_that_we_raise_when_error_not_thrown(self):
try:
Assert.raises(Exception, self._add_num, 5,4)
except AssertionError:
pass
def _divide_by_zero(self):
return 1/0
def _add_num(self, first, second):
return first + second
@pytest.mark.skip_selenium
def test_addon_type_fails_when_addon_is_not_in_results(self, testsetup):
addons_xml = AddOnsAPI(testsetup)
try:
Assert.raises(AttributeError, addons_xml.get_addon_type_id("Firepug") )
except AssertionError:
pass
#Assert.raises(AttributeError, addons_xml.get_addon_type_name("Firepug"))
@pytest.mark.skip_selenium
def test_addon_version_number_fails_when_addon_is_not_in_results(self, testsetup):
addons_xml = AddOnsAPI(testsetup)
Assert.raises(AttributeError, addons_xml.get_addon_version_number("Firepug"))
if __name__ == "__main__":
unittest.main()