コード例 #1
0
ファイル: test_pages.py プロジェクト: wpears/cfgov-refresh
 def test_context_for_page_with_office_location(self):
     region = mommy.make(Region, name="Mideastern", abbreviation="ME")
     office = mommy.make(Office, name="Zenith Office", abbreviation="ZE")
     state = mommy.make(State,
                        name="Winnemac",
                        abbreviation='WM',
                        region=region)
     office.cities.add(City(name='Zenith', state=state))
     page = self.prepare_job_listing_page(location=office)
     test_context = page.get_context(HttpRequest())
     self.assertEqual(len(test_context['states']), 0)
     self.assertEqual(len(test_context['cities']), 1)
     self.assertEqual(test_context['cities'][0].name, 'Zenith')
コード例 #2
0
ファイル: test_pages.py プロジェクト: wpears/cfgov-refresh
 def test_context_for_page_with_region_location(self):
     region = mommy.make(
         Region,
         name="Tri-State Area",
         abbreviation="TA",
     )
     state = mommy.make(State,
                        name="Unknown",
                        abbreviation='UN',
                        region=region)
     cities = ['Danville', 'Townsville']
     for city in cities:
         region.cities.add(City(name=city, state=state))
     page = self.prepare_job_listing_page(location=region)
     test_context = page.get_context(HttpRequest())
     self.assertEqual(len(test_context['states']), 1)
     self.assertEqual(test_context['states'][0], state.abbreviation)
     self.assertEqual(len(test_context['cities']), 2)
     self.assertIn(test_context['cities'][0].name, cities)