Skip to content

Commit

Permalink
Merge 66588d4 into b98c522
Browse files Browse the repository at this point in the history
  • Loading branch information
owenl131 committed Dec 9, 2017
2 parents b98c522 + 66588d4 commit 3f1755a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Binary file added api/sample_image.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,49 @@ def test_delete_permalink(self):
response = self.client.delete(url)
response = json.loads(response.content.decode('utf-8'))
self.assertEqual(response["removed"], True)


class CustomUploadSampleInputControllerTests(TestCase):

def setUp(self):
self.client = Client()
self.demo = {
"name": "test",
"id": 99,
"user_id": 99,
"address": "address",
"description": "description",
"footer_message": "footer_message",
"cover_image": "cover_image",
"terminal": True,
"timestamp": datetime.datetime.now().isoformat(),
"token": "token",
"status": "input"
}
Demo.objects.create(name=self.demo["name"],
id=self.demo["id"],
user_id=self.demo["user_id"],
address=self.demo["address"],
description=self.demo["description"],
footer_message=self.demo["footer_message"],
cover_image=self.demo["cover_image"],
terminal=self.demo["terminal"],
timestamp=self.demo["timestamp"],
token=self.demo["token"],
status=self.demo["status"])

def test_upload_sample_input_nofile(self):
response = self.client.post("/upload_sample_input",
{"demo_id": self.demo["id"]})
self.assertContains(response, '', None, 200)

def test_upload_sample_input(self):
with open('api/sample_image.png', 'rb') as f:
response = self.client.post(
"/upload_sample_input",
{"demo_id": self.demo["id"], "sample-image": f})
self.assertContains(response, '', None, 200)
response = json.loads(response.content.decode('utf-8'))
response = response[0]
self.assertEqual(int(response["type_of_input"]),
3, str(dir(response)))

0 comments on commit 3f1755a

Please sign in to comment.