test_case_forms.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from yandex_music import CaseForms
  2. class TestCaseForms:
  3. nominative = 'Илья'
  4. genitive = 'Ильи'
  5. dative = 'Илье'
  6. accusative = 'Илью'
  7. instrumental = 'Ильей'
  8. prepositional = 'Илье'
  9. def test_expected_values(self, case_forms):
  10. assert case_forms.nominative == self.nominative
  11. assert case_forms.genitive == self.genitive
  12. assert case_forms.dative == self.dative
  13. assert case_forms.accusative == self.accusative
  14. assert case_forms.instrumental == self.instrumental
  15. assert case_forms.prepositional == self.prepositional
  16. def test_de_json_none(self, client):
  17. assert CaseForms.de_json({}, client) is None
  18. def test_de_json_required(self, client):
  19. json_dict = {
  20. 'nominative': self.nominative,
  21. 'genitive': self.genitive,
  22. 'dative': self.dative,
  23. 'accusative': self.accusative,
  24. 'instrumental': self.instrumental,
  25. 'prepositional': self.prepositional,
  26. }
  27. case_forms = CaseForms.de_json(json_dict, client)
  28. assert case_forms.nominative == self.nominative
  29. assert case_forms.genitive == self.genitive
  30. assert case_forms.dative == self.dative
  31. assert case_forms.accusative == self.accusative
  32. assert case_forms.instrumental == self.instrumental
  33. assert case_forms.prepositional == self.prepositional
  34. def test_de_json_all(self, client):
  35. json_dict = {
  36. 'nominative': self.nominative,
  37. 'genitive': self.genitive,
  38. 'dative': self.dative,
  39. 'accusative': self.accusative,
  40. 'instrumental': self.instrumental,
  41. 'prepositional': self.prepositional,
  42. }
  43. case_forms = CaseForms.de_json(json_dict, client)
  44. assert case_forms.nominative == self.nominative
  45. assert case_forms.genitive == self.genitive
  46. assert case_forms.dative == self.dative
  47. assert case_forms.accusative == self.accusative
  48. assert case_forms.instrumental == self.instrumental
  49. assert case_forms.prepositional == self.prepositional
  50. def test_equality(self):
  51. a = CaseForms(
  52. self.nominative, self.genitive, self.dative, self.accusative, self.instrumental, self.prepositional
  53. )
  54. b = CaseForms(self.nominative, '', self.dative, self.accusative, self.instrumental, self.prepositional)
  55. c = CaseForms(
  56. self.nominative, self.genitive, self.dative, self.accusative, self.instrumental, self.prepositional
  57. )
  58. assert a != b
  59. assert hash(a) != hash(b)
  60. assert a is not b
  61. assert a == c