Commit 0117d91751a4f211e7fc803f0052f964c24e38b8

Authored by Chung Wang
1 parent c7885ab861
Exists in master

test hide flashcard

Showing 1 changed file with 19 additions and 2 deletions Side-by-side Diff

flashcards/tests/test_api.py View file @ 0117d91
... ... @@ -200,7 +200,8 @@
200 200 def setUp(self):
201 201 self.client.login(email='none@none.com', password='1234')
202 202 self.user = User.objects.get(email='none@none.com')
203   - self.flashcard = Flashcard(text="jason", section=Section.objects.get(pk=1), material_date=now(), author=self.user)
  203 + self.flashcard = Flashcard(text="jason", section=Section.objects.get(pk=1), material_date=now(),
  204 + author=self.user)
204 205 self.flashcard.save()
205 206 self.section = Section.objects.get(pk=1)
206 207  
... ... @@ -280,5 +281,21 @@
280 281 response = self.client.get('/api/sections/1/ordered_deck/')
281 282 self.assertEqual(response.status_code, HTTP_200_OK)
282 283  
283   - def test_hide_card(self):
  284 +
  285 +class FlashcardViewSetTest(APITestCase):
  286 + fixtures = ['testusers', 'testsections']
  287 +
  288 + def setUp(self):
  289 + self.client.login(email='none@none.com', password='1234')
  290 + self.user = User.objects.get(email='none@none.com')
  291 + self.flashcard = Flashcard(text="jason", section=Section.objects.get(pk=1), material_date=now(),
  292 + author=self.user)
  293 + self.flashcard.save()
  294 + self.section = Section.objects.get(pk=1)
  295 +
  296 + def test_hide_flashcard(self):
  297 + url = '/api/flashcards/1/hide/'
  298 + data = {1, ''}
  299 + response = self.client.post(url, data, format='json')
  300 + self.assertEqual(response.status_code, HTTP_204_NO_CONTENT)