Commit abd5c251 authored by Patrick Barroca's avatar Patrick Barroca 🐧

Merge branch 'hotline#106879_moissonnage_de_artevod' into 'hotline'

hotline #106879 : add country in ArteVOD harvest parameters

See merge request !3435
parents 9b7d03d1 ae093044
Pipeline #9713 passed with stage
in 44 minutes and 57 seconds
- ticket #106879 : ArteVOD : Correction du moissonnage pour filtrer les films selon le pays de diffusion, par défaut la France
\ No newline at end of file
......@@ -226,6 +226,8 @@ class Class_AdminVarLoader extends Storm_Model_Loader {
'ARTE_VOD_LOGIN' => Class_AdminVar_Meta::newDefault($this->_('Login utilisé pour générer l\'adresse https://vod.mediatheque-numerique.com/mediatheques/[ARTE VOD LOGIN]'))->bePrivate(),
'ARTE_VOD_KEY' => Class_AdminVar_Meta::newDefault($this->_('Clé de moissonnage (optionelle)'))->bePrivate(),
'ARTE_VOD_SSO_KEY' => Class_AdminVar_Meta::newDefault($this->_('Clé de cryptage lors du SSO'))->bePrivate(),
'ARTE_VOD_COUNTRY' => Class_AdminVar_Meta::newDefault($this->_('Pays de diffusion utilisé lors du moissonnage (par défaut FR, ALL pour ne pas filtrer)'),
['value' => 'FR'])->bePrivate(),
'NUMERIQUE_PREMIUM_URL' => Class_AdminVar_Meta::newDefault('')->bePrivate(),
......
......@@ -20,12 +20,18 @@
*/
class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumerique_Abstract {
const FILMS = 'films';
const CATEGORY_LABEL = 'ArteVOD';
const
FILMS = 'films',
CATEGORY_LABEL = 'ArteVOD',
COUNTRY_ALL = 'ALL';
public function getHarvestUrl($page_number){
return $this->getBaseUrl() . self::FILMS . '?page_nb=' . $page_number;
public function getHarvestUrl($page_number) {
$params = ['page_nb' => (int)$page_number];
if (static::COUNTRY_ALL !== ($country = Class_AdminVar::getValueOrDefault('ARTE_VOD_COUNTRY')))
$params['q_country'] = $country;
return $this->getBaseUrl() . static::FILMS . '?' . http_build_query($params);
}
......@@ -46,7 +52,8 @@ class Class_WebService_BibNumerique_ArteVOD extends Class_WebService_BibNumeriqu
public function open_authenticated_url($url) {
$client = $this->getWebClient();
return ($user = trim(Class_AdminVar::get('ARTE_VOD_LOGIN'))) && ($password = trim(Class_AdminVar::get('ARTE_VOD_KEY')))
return ($user = trim(Class_AdminVar::get('ARTE_VOD_LOGIN')))
&& ($password = trim(Class_AdminVar::get('ARTE_VOD_KEY')))
? $client->open_url($url, ['auth' => ['user' => $user,
'password' => $password]])
: $client->open_url($url);
......
......@@ -142,9 +142,12 @@ class Class_WebService_BibNumerique_ArteVOD_Config extends Class_Entity {
public function getAdminVarsInstances() {
return [ Class_AdminVar::find('ARTE_VOD_LOGIN'),
Class_AdminVar::find('ARTE_VOD_KEY'),
Class_AdminVar::find('ARTE_VOD_SSO_KEY')
Class_AdminVar::init();
return [Class_AdminVar::find('ARTE_VOD_LOGIN'),
Class_AdminVar::find('ARTE_VOD_KEY'),
Class_AdminVar::find('ARTE_VOD_SSO_KEY'),
Class_AdminVar::find('ARTE_VOD_COUNTRY'),
];
}
......
......@@ -64,7 +64,7 @@ class ArteVODHarverstingFourFilmsInTwoPages extends ArteVODHarverstingTestCase {
as $page => $answer) {
$this->_web_client
->whenCalled('open_url')
->with('https://vod.mediatheque-numerique.com/api/v1/films?page_nb=' . $page,
->with('https://vod.mediatheque-numerique.com/api/v1/films?page_nb=' . $page . '&q_country=FR',
$auth)
->answers($answer);
}
......@@ -227,7 +227,7 @@ class ArteVODHarvestingWithoutPasswordTest extends ArteVODHarverstingTestCase {
$this->_web_client
->whenCalled('open_url')
->with('https://vod.mediatheque-numerique.com/api/v1/films?page_nb=1')
->with('https://vod.mediatheque-numerique.com/api/v1/films?page_nb=1&q_country=FR')
->answers(ArteVODFixtures::emptyPage());
$this->_web_client->beStrict();
......@@ -245,6 +245,33 @@ class ArteVODHarvestingWithoutPasswordTest extends ArteVODHarverstingTestCase {
class ArteVODHarvestingWithoutCountryTest extends ArteVODHarverstingTestCase {
public function setUp() {
parent::setUp();
Class_AdminVar::set('ARTE_VOD_KEY', '');
Class_AdminVar::set('ARTE_VOD_COUNTRY', Class_WebService_BibNumerique_ArteVOD::COUNTRY_ALL);
$this->_web_client
->whenCalled('open_url')
->with('https://vod.mediatheque-numerique.com/api/v1/films?page_nb=1')
->answers(ArteVODFixtures::emptyPage());
$this->_web_client->beStrict();
(new Class_WebService_BibNumerique_ArteVOD())->harvest();
}
/** @test */
public function shouldHaveHarvestedWithoutCountry() {
$this->assertTrue($this->_web_client->methodHasBeenCalled('open_url'));
}
}
class ArteVODHarverstingEnablingTest extends ArteVODHarverstingTestCase {
/** @test */
public function withAllShouldBeEnabled() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment