def testFixCountries( self ): from film20.import_films.update_countries import update_all_films f1 = Film( type=1, imdb_code="123", release_year=2002, title="Fake 1", production_country_list="FrancePolandGermanyUK," ) f1.save() f2 = Film( type=1, imdb_code="456", release_year=2010, title="Fake 2", production_country_list="USAUKUnited Arab Emirates," ) f2.save() f3 = Film( type=1, imdb_code="789", release_year=2010, title="Fake 3", production_country_list="USA" ) f3.save() f4 = Film( type=1, imdb_code="111", release_year=2010, title="Fake 4", production_country_list="UK, Aasdasd asdas, ," ) f4.save() update_all_films() self.failUnlessEqual( Film.objects.get( pk=f1.pk ).production_country_list, "France,Poland,Germany,UK" ) self.failUnlessEqual( Film.objects.get( pk=f2.pk ).production_country_list, "USA,UK,United Arab Emirates" ) self.failUnlessEqual( Film.objects.get( pk=f3.pk ).production_country_list, "USA" ) self.failUnlessEqual( Film.objects.get( pk=f4.pk ).production_country_list, "UK" )
def testFixCountries(self): from film20.import_films.update_countries import update_all_films f1 = Film(type=1, imdb_code="123", release_year=2002, title="Fake 1", production_country_list="FrancePolandGermanyUK,") f1.save() f2 = Film(type=1, imdb_code="456", release_year=2010, title="Fake 2", production_country_list="USAUKUnited Arab Emirates,") f2.save() f3 = Film(type=1, imdb_code="789", release_year=2010, title="Fake 3", production_country_list="USA") f3.save() f4 = Film(type=1, imdb_code="111", release_year=2010, title="Fake 4", production_country_list="UK, Aasdasd asdas, ,") f4.save() update_all_films() self.failUnlessEqual( Film.objects.get(pk=f1.pk).production_country_list, "France,Poland,Germany,UK") self.failUnlessEqual( Film.objects.get(pk=f2.pk).production_country_list, "USA,UK,United Arab Emirates") self.failUnlessEqual( Film.objects.get(pk=f3.pk).production_country_list, "USA") self.failUnlessEqual( Film.objects.get(pk=f4.pk).production_country_list, "UK")
import os, sys PROJECT_ROOT = os.curdir os.environ['DJANGO_SETTINGS_MODULE'] = 'film20.settings' from film20.import_films.update_countries import update_all_films update_all_films()