def test_syncing_vocabulary_pulls_srs_level_successfully(self): mock_user_response_v2() mock_assignments_with_one_assignment() mock_study_materials() Syncer.factory(self.user.profile).sync_with_wk() newly_synced_review = UserSpecific.objects.get( user=self.user, vocabulary__meaning=self.v.meaning) self.assertEqual(newly_synced_review.wanikani_srs_numeric, 4)
def test_synonyms_are_ported_in_v2(self): mock_user_response_v2() mock_assignments_with_one_assignment() mock_study_materials() syncer = WanikaniUserSyncerV2(self.user.profile) syncer.sync_with_wk(full_sync=False) review = UserSpecific.objects.filter(user=self.user)[0] assert review.meaning_note is not None assert review.meaning_synonyms.count() == 3 assert "young lady" in review.synonyms_list()
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_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
def test_user_that_is_created_who_has_no_vocab_at_current_level_also_gets_previous_level_unlocked( self): # Create a user who is at level 2 on Wanikani, but has no level 2 vocab unlocked, only level 1 vocab. fake_username = "******" fake_api_key = "fake_api_key" mock_user_response_v2() mock_assignments_with_no_assignments() mock_assignments_with_one_assignment() mock_study_materials() self.client.post( reverse("api:auth:user-create"), data={ "username": fake_username, "password": "******", "api_key_v2": fake_api_key, "email": "*****@*****.**", }, ) user_profile = Profile.objects.get(user__username=fake_username) assert len(user_profile.unlocked_levels_list()) == 2