def test_creating_new_synonyms_on_sync(self): resp_body = deepcopy(sample_api_responses.single_vocab_response) resp_body["requested_information"][0]["user_specific"]["user_synonyms"] = ["kitten", "large rat"] responses.add(responses.GET, build_API_sync_string_for_user(self.user), json=resp_body, status=200, content_type='application/json') sync_unlocked_vocab_with_wk(self.user) self.assertListEqual(self.review.synonyms_list(), ["kitten", "large rat"])
def test_syncing_vocabulary_pulls_srs_level_successfully(self): resp_body = sample_api_responses.single_vocab_response responses.add(responses.GET, self._vocab_api_regex, json=resp_body, status=200, content_type='application/json') sync_unlocked_vocab_with_wk(self.user) newly_synced_review = UserSpecific.objects.get(user=self.user, vocabulary__meaning=self.vocabulary.meaning) self.assertEqual(newly_synced_review.wanikani_srs, "apprentice") self.assertEqual(newly_synced_review.wanikani_srs_numeric, 3)
def test_when_wanikani_changes_meaning_no_duplicate_is_created(self): resp_body = deepcopy(sample_api_responses.single_vocab_response) resp_body['requested_information'][0]['meaning'] = "NOT radioactive bat" # Mock response so that the level changes on our default vocab. responses.add(responses.GET, build_API_sync_string_for_user_for_levels(self.user, [self.user.profile.level, ]), json=resp_body, status=200, content_type='application/json') sync_unlocked_vocab_with_wk(self.user) # Will fail if 2 vocab exist with same kanji. vocabulary = get_vocab_by_kanji("猫")
def test_when_reading_level_changes_on_wanikani_we_catch_that_change_and_comply(self): resp_body = sample_api_responses.single_vocab_response # Mock response so that the level changes on our default vocab. responses.add(responses.GET, self._vocab_api_regex, json=sample_api_responses.single_vocab_response, status=200, content_type='application/json') sync_unlocked_vocab_with_wk(self.user) vocabulary = Vocabulary.objects.get(meaning="radioactive bat") self.assertEqual(vocabulary.readings.count(), 1)
def test_when_reading_level_changes_on_wanikani_we_catch_that_change_and_comply(self): resp_body = sample_api_responses.single_vocab_response #Mock response so that the level changes on our default vocab. responses.add(responses.GET, build_API_sync_string_for_user(self.user), json=sample_api_responses.single_vocab_response, status=200, content_type='application/json') sync_unlocked_vocab_with_wk(self.user) vocabulary = get_vocab_by_meaning("radioactive bat") self.assertEqual(vocabulary.reading_set.count(), 1)
def test_syncing_vocabulary_pulls_srs_level_successfully(self): resp_body = sample_api_responses.single_vocab_response responses.add( responses.GET, self._vocab_api_regex, json=resp_body, status=200, content_type="application/json", ) sync_unlocked_vocab_with_wk(self.user) newly_synced_review = UserSpecific.objects.get( user=self.user, vocabulary__meaning=self.vocabulary.meaning ) self.assertEqual(newly_synced_review.wanikani_srs, "apprentice") self.assertEqual(newly_synced_review.wanikani_srs_numeric, 3)
def test_when_wanikani_changes_meaning_no_duplicate_is_created(self): resp_body = deepcopy(sample_api_responses.single_vocab_response) resp_body["requested_information"][0]["meaning"] = "NOT radioactive bat" # Mock response so that the level changes on our default vocab. responses.add( responses.GET, build_API_sync_string_for_user_for_levels( self.user, [self.user.profile.level] ), json=resp_body, status=200, content_type="application/json", ) sync_unlocked_vocab_with_wk(self.user) # Will fail if 2 vocab exist with same kanji. vocabulary = get_vocab_by_kanji("猫")
def test_when_reading_level_changes_on_wanikani_we_catch_that_change_and_comply( self ): resp_body = sample_api_responses.single_vocab_response # Mock response so that the level changes on our default vocab. responses.add( responses.GET, self._vocab_api_regex, json=sample_api_responses.single_vocab_response, status=200, content_type="application/json", ) sync_unlocked_vocab_with_wk(self.user) vocabulary = Vocabulary.objects.get(meaning="radioactive bat") self.assertEqual(vocabulary.readings.count(), 1)
def test_creating_new_synonyms_on_sync(self): resp_body = deepcopy(sample_api_responses.single_vocab_response) resp_body["requested_information"][0]["user_specific"]["user_synonyms"] = [ "kitten", "large rat", ] responses.add( responses.GET, self._vocab_api_regex, json=resp_body, status=200, content_type="application/json", ) sync_unlocked_vocab_with_wk(self.user) synonyms_list = self.review.synonyms_list() self.assertIn("large rat", synonyms_list) self.assertIn("kitten", synonyms_list)