-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrated setUp and tearDown with tests
- Loading branch information
Showing
2 changed files
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,34 +25,32 @@ def tearDown(self): | |
|
||
class InspectUserTestCase(TestCase): | ||
fixtures = ['db'] # load from DB | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def test_user_attributes(self): | ||
#add users | ||
c = Client() | ||
|
||
self.client = Client() | ||
user_name = random.randrange(0,200) | ||
c = Client() | ||
form_data = {'username': 'abolishputa'+str(user_name),'password': 'Lettish_fundamentalism100', 'email_address': '[email protected]','date_joined': datetime.datetime.now(), 'is_active': True, 'f_name': 'Mark', 'l_name': 'White','bio': "a zoonal" } | ||
|
||
form = views.UserForm(data=form_data) | ||
self.assertTrue(form.is_valid()) | ||
response = c.post(reverse('create_user'), form_data) | ||
print("test_user_attributes POST " + str(response)) | ||
|
||
response = self.client.post(reverse('create_user'), form_data) | ||
print("test_user_attributes POST " + str(response)) | ||
|
||
resp = json.loads(response.content.decode('utf8')) | ||
print("user atts " + str(resp)) | ||
self.assertEquals(response.status_code, 200) | ||
|
||
response = c.get(reverse('inspect_user', kwargs={'user_id':201})) | ||
# append number to test to get python to run defs in correct order | ||
def test1_user_attributes(self): | ||
|
||
response = self.client.get(reverse('inspect_user', kwargs={'user_id':201})) | ||
resp = json.loads(response.content.decode('utf8')) | ||
|
||
print("test_user_attributes GET " + str(resp)) | ||
self.assertEquals(resp["ok"],True) | ||
self.assertEquals(resp['resp']['f_name'], 'Mark') | ||
def test_fails_invalid(self): | ||
|
||
def test2_fails_invalid_user(self): | ||
response = self.client.get(reverse('inspect_user', kwargs=None)) | ||
self.assertEquals(response.status_code, 200) | ||
|
||
|
@@ -64,7 +62,7 @@ def test_fails_invalid(self): | |
self.assertEquals(resp["ok"],False) | ||
|
||
def tearDown(self): | ||
pass | ||
del self.client | ||
|
||
#experience tests bonus | ||
#this project is read ony? | ||
|