Created
March 27, 2012 17:28
-
-
Save thepug/2218203 to your computer and use it in GitHub Desktop.
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
class ApiTTests(TestCase): | |
fixtures = ['auth_views_testdata.json'] | |
def setUp(self): | |
email = "w0" | |
user = User.objects.create_user(username=email, email=email) | |
user.set_unusable_password() | |
user.jid = email | |
user.save() | |
user.apikey = get_api_key(user) | |
print "Created user: %s" % user.username | |
print "Has API key: %s" % user.apikey | |
self.api_key = user.apikey | |
self.username = user.username | |
def test_new_ticket(self): | |
# create new ticket | |
test_data = { | |
"username":self.username, | |
"api_key":self.api_key | |
} | |
header = { | |
"HTTP_AUTHORIZATION": "ApiKey %s:%s" % (self.username, self.api_key) | |
} | |
response = self.client.put('/api/v1/t/', json.dumps(test_data), content_type="application/json", **header) | |
self.assertEqual(response.status_code, 201) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment