Commit 61c43267c4b24a72524529d514bdcaa7506b6bca
1 parent
c91a932f6e
Exists in
master
Fixed accidental push.
Showing 1 changed file with 23 additions and 4 deletions Side-by-side Diff
flashcards/tests/test_api.py
View file @
61c4326
1 | 1 | from django.core import mail |
2 | 2 | from flashcards.models import * |
3 | -from rest_framework.status import HTTP_204_NO_CONTENT, HTTP_201_CREATED, HTTP_200_OK, HTTP_403_FORBIDDEN | |
3 | +from rest_framework.status import HTTP_204_NO_CONTENT, HTTP_201_CREATED, HTTP_200_OK, HTTP_403_FORBIDDEN, HTTP_404_NOT_FOUND | |
4 | 4 | from rest_framework.test import APITestCase |
5 | 5 | from re import search |
6 | 6 | from django.utils.timezone import now |
... | ... | @@ -187,6 +187,27 @@ |
187 | 187 | self.flashcard = Flashcard(text="jason", section=section, material_date=now(), author=user) |
188 | 188 | self.flashcard.save() |
189 | 189 | |
190 | + def test_edit_flashcard(self): | |
191 | + self.client.login(email='none@none.com', password='1234') | |
192 | + user = User.objects.get(email='none@none.com') | |
193 | + user.sections.add(Section.objects.get(pk=1)) | |
194 | + user.save() | |
195 | + | |
196 | + def test_create_flashcard(self): | |
197 | + self.client.login(email='none@none.com', password='1234') | |
198 | + user = User.objects.get(email='none@none.com') | |
199 | + user.sections.add(Section.objects.get(pk=1)) | |
200 | + user.save() | |
201 | + data = {'text': 'this is a flashcard', | |
202 | + 'material_date': str(datetime.now()), | |
203 | + 'mask': '[]', | |
204 | + 'section': '1', | |
205 | + 'previous': None} | |
206 | + response = self.client.post("/api/flashcards/", data, format="json") | |
207 | + self.assertEqual(response.status_code, HTTP_201_CREATED) | |
208 | + self.assertEqual(response.data['text'], data['text']) | |
209 | + self.assertTrue(Flashcard.objects.filter(section__pk=1, text=data['text']).exists()) | |
210 | + | |
190 | 211 | def test_get_flashcard(self): |
191 | 212 | self.client.login(email='none@none.com', password='1234') |
192 | 213 | response = self.client.get("/api/flashcards/%d/" % self.flashcard.id, format="json") |
... | ... | @@ -279,6 +300,4 @@ |
279 | 300 | self.user.save() |
280 | 301 | response = self.client.get('/api/sections/1/ordered_deck/') |
281 | 302 | self.assertEqual(response.status_code, HTTP_200_OK) |
282 | - | |
283 | - def test_hide_card(self): |