'Check that course is imported successfully in existing course and users have their access roles'

def test_import_in_existing_course(self):

    (__, nonstaff_user) = self.create_non_staff_authed_user_client()
    auth.add_users(self.user, CourseStaffRole(self.course.id), nonstaff_user)
    course = self.store.get_course(self.course.id)
    self.assertIsNotNone(course)
    display_name_before_import = course.display_name
    with open(self.good_tar) as gtar:
        args = {'name': self.good_tar, 'course-data': [gtar]}
        resp = self.client.post(self.url, args)
    self.assertEquals(resp.status_code, 200)
    course = self.store.get_course(self.course.id)
    self.assertIsNotNone(course)
    display_name_after_import = course.display_name
    self.assertNotEqual(display_name_before_import, display_name_after_import)
    self.assertFalse(CourseInstructorRole(self.course.id).has_user(nonstaff_user))
    self.assertTrue(CourseStaffRole(self.course.id).has_user(nonstaff_user))
    self.client.login(username=nonstaff_user.username, password='foo')
    with open(self.good_tar) as gtar:
        args = {'name': self.good_tar, 'course-data': [gtar]}
        resp = self.client.post(self.url, args)
    self.assertEquals(resp.status_code, 200)
    self.assertFalse(CourseInstructorRole(self.course.id).has_user(nonstaff_user))
    self.assertTrue(CourseStaffRole(self.course.id).has_user(nonstaff_user))
