<s> from nose . tools import * <EOL> from tests . base import OsfTestCase <EOL> from tests . factories import UserFactory <EOL> from scripts . migration . migrate_mailing_lists_to_mailchimp_field import main , get_users_with_no_mailchimp_mailing_lists <EOL> class TestMigrateMailingLists ( OsfTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestMigrateMailingLists , self ) . setUp ( ) <EOL> self . user1 = UserFactory ( mailing_lists = { '<STR_LIT>' : True } ) <EOL> self . user2 = UserFactory ( mailing_lists = { '<STR_LIT>' : False } ) <EOL> self . user3 = UserFactory ( ) <EOL> self . user1 . save ( ) <EOL> self . user2 . save ( ) <EOL> def test_get_users_with_mailing_lists ( self ) : <EOL> users_with_mailing_list_ids = [ user . _id for user in get_users_with_no_mailchimp_mailing_lists ( ) ] <EOL> assert_equal ( len ( users_with_mailing_list_ids ) , <NUM_LIT:2> ) <EOL> assert_true ( self . user1 . _id in users_with_mailing_list_ids ) <EOL> assert_true ( self . user2 . _id in users_with_mailing_list_ids ) <EOL> assert_false ( self . user3 . _id in users_with_mailing_list_ids ) <EOL> def test_migration_of_mailing_lists ( self ) : <EOL> assert_equal ( self . user1 . mailchimp_mailing_lists , { } ) <EOL> assert_equal ( self . user2 . mailchimp_mailing_lists , { } ) <EOL> main ( ) <EOL> self . user1 . reload ( ) <EOL> self . user2 . reload ( ) <EOL> assert_true ( self . user1 . mailchimp_mailing_lists . get ( u'<STR_LIT>' ) ) <EOL> assert_false ( self . user2 . mailchimp_mailing_lists . get ( u'<STR_LIT>' ) ) </s>
