def test_sync_content(self, stdout, mock_prepare_event, mock_prepare_content): command = FakeSyncCommand() synchro = SyncRando(command) synchro.sync_content('fr', self.touristic_content) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'touristiccontents', str(self.touristic_content.pk), '%s.pdf' % self.touristic_content.slug)))
def test_sync_detail_no_portal_no_source(self, stdout, mock_prepare): command = FakeSyncCommand() synchro = SyncRando(command) synchro.sync_detail('fr', self.trek) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), '%s.pdf' % self.trek.slug))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'pois.geojson'))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'dem.json'))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'profile.png'))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'touristiccontents.geojson'))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'touristicevents.geojson')))
def test_sync_event_portal_source(self, stdout, mock_prepare_event, mock_prepare_content): command = FakeSyncCommand(portal=self.portal.name, source=[self.source.name]) synchro = SyncRando(command) synchro.sync_event('fr', self.touristic_event) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'touristicevents', str(self.touristic_event.pk), '%s.pdf' % self.touristic_event.slug)))
def test_feedback(self, stdout): command = FakeSyncCommand() synchro = SyncRando(command) synchro.sync('en') self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'feedback', 'categories.json')))
def test_sync_language_portal_source(self, stdout, mock_prepare): def side_effect_sync(lang, dive): self.assertEqual(dive, self.dive_portal_source) command = FakeSyncCommand(portal=self.portal_a.name, source=[self.source_a.name]) synchro = SyncRando(command) with patch('geotrek.diving.helpers_sync.SyncRando.sync_detail', side_effect=side_effect_sync) as mock_dive: synchro.sync('en') self.assertEqual(len(mock_dive.call_args_list), 1) mock_dive.assert_called_with('en', self.dive_portal_source)
def test_sync_language(self, stdout, mock_prepare): def side_effect_sync(lang, trek): pass command = FakeSyncCommand() synchro = SyncRando(command) with patch('geotrek.diving.helpers_sync.SyncRando.sync_detail', side_effect=side_effect_sync) as mock_dive: synchro.sync('en') self.assertEqual(len(mock_dive.call_args_list), 3) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'dives.geojson')))
def test_signage(self, mock_stdout): command = FakeSyncCommand() synchro = SyncRando(command) synchro.sync('en') self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'signages.geojson'))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'static', 'signage', 'picto-signage.png')))
def test_sync_detail_portal_source(self, stdout, mock_prepare): command = FakeSyncCommand(portal=self.portal_b.name, source=[self.source_b.name]) synchro = SyncRando(command) synchro.sync_detail('fr', self.dive) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'dives', str(self.dive.pk), '%s.pdf' % self.dive.slug))) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'dives', str(self.dive.pk), 'pois.geojson'))) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'dives', str(self.dive.pk), 'touristiccontents.geojson'))) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'dives', str(self.dive.pk), 'touristicevents.geojson')))
def test_sync_language_portal_source(self, stdout, mock_prepare): def side_effect_sync(lang, trek): self.assertEqual(trek, self.trek_fr) command = FakeSyncCommand(portal=self.portal_a.name, source=[self.source_b.name]) synchro = SyncRando(command) with patch('geotrek.trekking.helpers_sync.SyncRando.sync_detail', side_effect=side_effect_sync) as mock_trek: synchro.sync('fr') self.assertEqual(len(mock_trek.call_args_list), 1) mock_trek.assert_called_with('fr', self.trek_fr)
def test_sensitivity(self, mock_stdout): command = FakeSyncCommand() synchro = SyncRando(command) synchro.sync('en') self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'sensitiveareas.geojson'))) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'sensitiveareas', '{obj.pk}.kml'.format(obj=self.area))))
def test_sync_language(self, stdout, mock_prepare): def side_effect_sync(lang, trek): self.assertEqual(trek, self.trek_fr) command = FakeSyncCommand() synchro = SyncRando(command) with patch('geotrek.trekking.helpers_sync.SyncRando.sync_detail', side_effect=side_effect_sync): synchro.sync('fr') self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'static', 'trekking', 'trek.svg')))
def test_sync(self, stdout, mock_prepare_event, mock_prepare_content): def side_effect_sync_event(lang, event): self.assertEqual(event, self.touristic_event) def side_effect_sync_content(lang, content): self.assertEqual(content, self.touristic_content) command = FakeSyncCommand() synchro = SyncRando(command) with patch('geotrek.tourism.helpers_sync.SyncRando.sync_event', side_effect=side_effect_sync_event): with patch('geotrek.tourism.helpers_sync.SyncRando.sync_content', side_effect=side_effect_sync_content): synchro.sync('en') self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'static', 'tourism', 'touristicevent.svg'))) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'information_desks.geojson')))
def test_sync_detail_booklet(self, stdout, mock_prepare): command = FakeSyncCommand(skip_dem=True, skip_profile_png=True) synchro = SyncRando(command) with override_settings(USE_BOOKLET_PDF=False): synchro.sync_detail('en', self.trek) first_file = os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'treks', str(self.trek.pk), '%s.pdf' % self.trek.slug) size_first = os.stat(first_file).st_size with override_settings(USE_BOOKLET_PDF=True): synchro.sync_detail('en', self.trek) second_file = os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'treks', str(self.trek.pk), '%s.pdf' % self.trek.slug) size_second = os.stat(second_file).st_size self.assertLess(size_first, size_second)
def test_sync_portal_source(self, stdout, mock_prepare_event, mock_prepare_content): def side_effect_sync_event(lang, event): self.assertEqual(event, self.touristic_event_p_s) def side_effect_sync_content(lang, content): self.assertEqual(content, self.touristic_content_p_s) self.touristic_content_p_s = TouristicContentFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, sources=(self.source,), portals=(self.portal,), published=True) self.touristic_event_p_s = TouristicEventFactory( geom='SRID=%s;POINT(700001 6600001)' % settings.SRID, sources=(self.source,), portals=(self.portal,), published=True) command = FakeSyncCommand(portal=self.portal.name, source=[self.source.name]) synchro = SyncRando(command) with patch('geotrek.tourism.helpers_sync.SyncRando.sync_event', side_effect=side_effect_sync_event): with patch('geotrek.tourism.helpers_sync.SyncRando.sync_content', side_effect=side_effect_sync_content): synchro.sync('en') self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'static', 'tourism', 'touristicevent.svg'))) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'en', 'information_desks.geojson')))
def test_sync_detail_no_portal_no_source_skip_everything( self, stdout, mock_prepare): command = FakeSyncCommand(skip_dem=True, skip_pdf=True, skip_profile_png=True) synchro = SyncRando(command) synchro.sync_detail('fr', self.trek) self.assertTrue( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'pois.geojson'))) self.assertFalse( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), '%s.pdf' % self.trek.slug))) self.assertFalse( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'dem.json'))) self.assertFalse( os.path.exists( os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'treks', str(self.trek.pk), 'profile.png')))
def test_sync_detail_no_portal_no_source(self, stdout, mock_prepare): command = FakeSyncCommand() synchro = SyncRando(command) synchro.sync_detail('fr', self.dive) self.assertTrue(os.path.exists(os.path.join('var', 'tmp_sync_rando', 'api', 'fr', 'dives', str(self.dive.pk), '%s.pdf' % self.dive.slug)))