4
4
5
5
from datetime import datetime , timedelta
6
6
from github3 import exceptions , GitHubError
7
- from github3 .models import GitHubCore , GitHubObject
7
+ from github3 .models import GitHubCore
8
8
from unittest import TestCase
9
9
from . import helper
10
10
@@ -18,16 +18,6 @@ def __init__(self, example_data, session=None):
18
18
self .etag = example_data ['etag' ]
19
19
20
20
21
- class MyGetAttrTestClass (GitHubObject ):
22
- """Subclass for testing getattr on GitHubObject."""
23
-
24
- def __init__ (self , example_data , session = None ):
25
- super (MyGetAttrTestClass , self ).__init__ (example_data )
26
-
27
- def _update_attributes (self , json_data ):
28
- self .fake_attr = json_data
67ED
span>.get ('fake_attr' )
29
-
30
-
31
21
class TestGitHubError (TestCase ):
32
22
"""Test methods on GitHubError class."""
33
23
@@ -55,30 +45,6 @@ def test_str(self):
55
45
assert str (self .instance ) == '400 m'
56
46
57
47
58
- class TestGitHubObject (helper .UnitHelper ):
59
- """Test methods on GitHubObject class."""
60
-
61
- described_class = MyGetAttrTestClass
62
- example_data = {
63
- 'fake_attr' : 'foo' ,
64
- 'another_fake_attr' : 'bar'
65
- }
66
-
67
- def test_from_json (self ):
68
- """Verify that method returns GitHubObject from json."""
69
- github_object = GitHubObject .from_json ('{}' )
70
- assert isinstance (github_object , GitHubObject )
71
-
72
- def test_exposes_attributes (self ):
73
- """Verify JSON attributes are exposed even if not explicitly set."""
74
- assert self .instance .another_fake_attr == 'bar'
75
-
76
- def test_missingattribute (self ):
77
- """Test AttributeError is raised when attribute is not in JSON."""
78
- with pytest .raises (AttributeError ):
79
- self .instance .missingattribute
80
-
81
-
82
48
class TestGitHubCore (helper .UnitHelper ):
83
49
84
50
described_class = MyTestRefreshClass
@@ -90,7 +56,8 @@ class TestGitHubCore(helper.UnitHelper):
90
56
example_data = {
91
57
'url' : url ,
92
58
'last_modified' : last_modified ,
93
- 'etag' : etag
59
+ 'etag' : etag ,
60
+ 'fake_attr' : 'foo' ,
94
61
}
95
62
96
63
def test_boolean (self ):
@@ -130,6 +97,15 @@ def test_boolean_empty_response(self):
130
97
131
98
assert boolean is False
132
99
100
+ def test_exposes_attributes (self ):
101
+ """Verify JSON attributes are exposed even if not explicitly set."""
102
+ assert self .instance .fake_attr == 'foo'
103
+
104
+ def test_from_json (self ):
105
+ """Verify that method returns GitHubObject from json."""
106
+ github_core = GitHubCore .from_json ('{}' )
107
+ assert isinstance (github_core , GitHubCore )
108
+
133
109
def test_json (self ):
134
110
"""Verify JSON information is retrieved correctly."""
135
111
response = requests .Response ()
@@ -150,6 +126,11 @@ def test_json_status_code_does_not_match(self):
150
126
json = self .instance ._json (response , 200 )
151
127
assert json is None
152
128
129
+ def test_missingattribute (self ):
130
+ """Test AttributeError is raised when attribute is not in JSON."""
131
+ with pytest .raises (AttributeError ):
132
+ self .instance .missingattribute
133
+
153
134
def test_refresh (self ):
154
135
"""Verify the request of refreshing an object."""
155
136
instance = self .instance .refresh ()
0 commit comments