Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. from django.test import TestCase
  2. import datetime
  3.  
  4. from django.utils import timezone
  5. from django.test import TestCase
  6.  
  7. from .models import *
  8.  
  9.  
  10. # Create your tests here.
  11.  
  12.  
  13. class QuestionModelTests(TestCase):
  14.  
  15. @classmethod
  16. def setUpTestData(cls):
  17. #FIXME: spits out django.db.utils.IntegrityError: UNIQUE constraint failed
  18. test_user = User.objects.create_user(username='tester', email='tester@test.com', password='asd')
  19. test_user.save()
  20.  
  21. test_profile = Profile(
  22. user=test_user,
  23. is_developer=True,
  24. )
  25. test_profile.save()
  26.  
  27. test_game = Game(
  28. title="testing game",
  29. description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
  30. URL="http://webcourse.cs.hut.fi/example_game.html",
  31. release_date=datetime.datetime.today(),
  32. price=10,
  33. reviews=None,
  34. developer=test_profile,
  35. imgURL="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/Emacs_Tetris_vector_based_detail.svg/2000px-Emacs_Tetris_vector_based_detail.svg.png"
  36. )
  37. test_game.save()
  38.  
  39.  
  40. def test_was_published_recently_with_future_question(self):
  41. """
  42. was_published_recently() returns False for questions whose pub_date
  43. is in the future.
  44. """
  45. #time = timezone.now() + datetime.timedelta(days=30)
  46. #future_question = Question(pub_date=time)
  47. #self.assertIs(future_question.was_published_recently(), False)
  48. pass
  49.  
  50. def test_creation(self):
  51. self.assertEqual(test_game.developer, test_profile)
  52. self.assertEqual(test_game.tags, test_tag)
  53. self.assertTrue(test_profile.is_developer)
  54.  
  55. def test_game_methods(self):
  56. self.assertEqual(str(test_game), "testing game")
  57. self.assertEqual(test_game.owners, 0)
  58. test_profile.games_owned.add(test_game)
  59. self.assertEqual(test_game.owners, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement