 Issue 29361729:
  Issue 4574 - Adds Tests to createNightlies platform specific revisions  (Closed)
    
  
    Issue 29361729:
  Issue 4574 - Adds Tests to createNightlies platform specific revisions  (Closed) 
  | Index: sitescripts/extensions/test/test_createNightlies.py | 
| =================================================================== | 
| --- a/sitescripts/extensions/test/test_createNightlies.py | 
| +++ b/sitescripts/extensions/test/test_createNightlies.py | 
| @@ -9,30 +9,56 @@ | 
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| # GNU General Public License for more details. | 
| # | 
| # You should have received a copy of the GNU General Public License | 
| # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| """Tests for create nightlies script.""" | 
| +import subprocess | 
| import pytest | 
| +import os | 
| 
Sebastian Noack
2016/11/07 16:24:41
As per PEP-8, corelib imports are supposed to go a
 
Jon Sonesen
2016/11/08 17:29:45
Acknowledged.
 | 
| from sitescripts.extensions.bin import createNightlies | 
| from sitescripts.utils import get_config | 
| -@pytest.fixture() | 
| +@pytest.fixture(scope='session') | 
| def config(hg_dir): | 
| + """Set and return config obj for NightlyBuild""" | 
| config = get_config() | 
| config.type = 'safari' | 
| - config.repository = str(hg_dir.join('adblockplusnightly')) | 
| config.revision = 'safari' | 
| + config.repositoryName = 'adblockplusnightly' | 
| + config.repository = hg_dir.join('adblockplusnightly').strpath | 
| 
Jon Sonesen
2016/11/04 15:11:55
I prefer to use strpath rather than the explicit c
 
Vasily Kuznetsov
2016/11/07 14:53:21
I'm not sure which way is preferable to be honest.
 
Jon Sonesen
2016/11/08 17:29:45
Yeah I spent some time trying to research it but d
 | 
| return config | 
| -@pytest.fixture() | 
| +@pytest.fixture(scope='session') | 
| def nightlybuild(config): | 
| return createNightlies.NightlyBuild(config) | 
| +@pytest.fixture(scope='session') | 
| +def nightlydir(hg_dir): | 
| + return hg_dir.join('adblockplusnightly') | 
| + | 
| + | 
| +@pytest.fixture(scope='session') | 
| +def current_revision(nightlydir): | 
| + command = [ | 
| + 'hg', 'id', '-R', nightlydir.strpath, '-i', '-r', 'ancestors(safari)'] | 
| 
Sebastian Noack
2016/11/07 16:24:41
The brackets look somewhat misplaced. I'm frankly
 
Vasily Kuznetsov
2016/11/07 17:11:00
PEP-8 actually allows this style (that's why flake
 
Jon Sonesen
2016/11/08 17:29:45
Acknowledged.
Also I can open a ticket to add thi
 | 
| + | 
| + return subprocess.check_output(command).strip() | 
| 
Jon Sonesen
2016/11/04 15:11:55
Personally, I don't like this approach. It seems t
 
Vasily Kuznetsov
2016/11/07 14:53:21
Sounds good, that would be an improvement.
 
Jon Sonesen
2016/11/08 17:29:45
Acknowledged.
 | 
| + | 
| + | 
| def test_nightly_object_bookmark(nightlybuild): | 
| assert nightlybuild.config.revision == 'safari' | 
| + | 
| + | 
| +def test_current_revision(current_revision, nightlybuild): | 
| + assert nightlybuild.revision == current_revision | 
| + | 
| + | 
| +def test_copy_repository(nightlybuild, nightlydir): | 
| + nightlybuild.copyRepository() | 
| + assert os.listdir(nightlybuild.tempdir) == os.listdir(nightlydir.strpath) | 
| 
Jon Sonesen
2016/11/04 15:11:55
an alternative approach...or maybe even just anoth
 
Vasily Kuznetsov
2016/11/07 14:53:21
So which behavior would we be testing with this?
 
Jon Sonesen
2016/11/08 17:29:45
copyRepository copies the specific bookmark to bui
 |