def test_vocabulary_auxiliary_meanings_changes_carry_over(self): mock_subjects_v2() syncer = WanikaniUserSyncerV2(self.user.profile) assert self.v.auxiliary_meanings_whitelist is None updated_vocabulary_count = syncer.sync_top_level_vocabulary() assert updated_vocabulary_count == 1 self.v.refresh_from_db() assert self.v.auxiliary_meanings_whitelist == "1,uno"
def test_vocabulary_meaning_changes_carry_over(self): mock_subjects_v2() syncer = WanikaniUserSyncerV2(self.user.profile) assert self.v.meaning == "radioactive bat" updated_vocabulary_count = syncer.sync_top_level_vocabulary() assert updated_vocabulary_count == 1 self.v.refresh_from_db() assert self.v.meaning == "One"
def test_registration(self): mock_subjects_v2() mock_assignments_with_one_assignment() mock_user_response_v2() mock_study_materials() response = self.client.post( reverse("api:auth:user-create"), data={ "username": "******", "password": "******", "api_key_v2": constants.API_KEY_V2, "email": "*****@*****.**", }, ) assert response.status_code == 201
def test_full_sync_of_user_on_v2(self): # Setup mocks for user response and full sync (with a single assignment) mock_user_response_v2() mock_assignments_with_one_assignment() mock_study_materials() mock_subjects_v2() self.user.profile.api_key_v2 = "whatever" self.user.profile.save() syncer = WanikaniUserSyncerV2(self.user.profile) syncer.sync_with_wk(full_sync=True) reviews = get_users_current_reviews(self.user) assert reviews.count() == 1
def test_creating_new_synonyms_for_users_who_arent_being_followed(self): # Mock synonyms response for V2. mock_user_response_v2() mock_subjects_v2() mock_assignments_with_one_assignment() mock_study_materials() # sync_unlocked_vocab_with_wk(self.user) self.user.profile.follow_me = False self.user.profile.save() sync_with_wk(self.user.id) synonyms_list = self.review.synonyms_list() self.assertIn("young girl", synonyms_list) self.assertIn("young lady", synonyms_list) self.assertIn("young miss", synonyms_list)
def test_vocabulary_reading_changes_carry_over(self): mock_subjects_v2() syncer = WanikaniUserSyncerV2(self.user.profile) assert self.v.readings.count() == 1 assert self.v.readings.all()[0].kana == "ねこ" updated_vocabulary_count = syncer.sync_top_level_vocabulary() assert updated_vocabulary_count == 1 self.v.refresh_from_db() expected_reading_kanas = [ reading.kana for reading in self.v.readings.all() ] expected_reading_kanjis = [ reading.character for reading in self.v.readings.all() ] assert "いち" in expected_reading_kanas assert "一" in expected_reading_kanjis assert "one - but in japanese" in expected_reading_kanas
def test_users_not_following_wanikani_still_get_vocab_unlocked_when_they_unlock_a_level( self): mock_user_response_v2() mock_assignments_with_one_assignment() mock_study_materials() mock_subjects_v2() self.user.profile.follow_me = False self.user.profile.api_key_v2 = "whatever" # Clear out all reviews so a level unlock works. UserSpecific.objects.filter(user=self.user).delete() syncer = WanikaniUserSyncerV2(self.user.profile) reviews = get_users_current_reviews(self.user) assert reviews.count() == 0 new_review_count, unlocked_count, locked_count = syncer.unlock_vocab( levels=[1]) assert new_review_count == 1 reviews = get_users_lessons(self.user) assert reviews.count() == 1