OLD | NEW |
(Empty) | |
| 1 # This file is part of the Adblock Plus web scripts, |
| 2 # Copyright (C) 2006-2016 Eyeo GmbH |
| 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. |
| 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. |
| 12 # |
| 13 # You should have received a copy of the GNU General Public License |
| 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
| 16 """Tests for create nightlies script.""" |
| 17 import os |
| 18 from subprocess import CalledProcessError |
| 19 |
| 20 import pytest |
| 21 |
| 22 from sitescripts.extensions.bin import createNightlies |
| 23 from sitescripts.utils import get_config |
| 24 |
| 25 # @pytest.fixture(scope='session') |
| 26 # def expected_changes(): |
| 27 # return {} |
| 28 @pytest.fixture(scope='session') |
| 29 def config(hg_dir): |
| 30 """Set and return config obj for NightlyBuild""" |
| 31 config = get_config() |
| 32 config.type = 'safari' |
| 33 config.revision = 'safari' |
| 34 config.repositoryName = 'adblockplusnightly' |
| 35 config.repository = hg_dir.join('adblockplusnightly').strpath |
| 36 return config |
| 37 |
| 38 |
| 39 @pytest.fixture(scope='session') |
| 40 def nightlybuild(config): |
| 41 return createNightlies.NightlyBuild(config) |
| 42 |
| 43 |
| 44 @pytest.fixture(scope='session') |
| 45 def current_revision(nightlydir): |
| 46 return '1291590ddd0f' |
| 47 |
| 48 |
| 49 def test_nightly_object_bookmark(nightlybuild): |
| 50 assert nightlybuild.config.revision == 'safari' |
| 51 |
| 52 |
| 53 def test_current_revision(current_revision, nightlybuild): |
| 54 assert nightlybuild.revision == current_revision |
| 55 |
| 56 |
| 57 def test_copy_repository(nightlybuild, nightlydir): |
| 58 nightlybuild.copyRepository() |
| 59 assert os.listdir(nightlybuild.tempdir) == os.listdir(nightlydir.strpath) |
| 60 |
| 61 |
| 62 def test_create_changes(nightlybuild, nightlydir): |
| 63 for change in nightlybuild.getChanges(): |
| 64 for key, value in change.items()1 |
| 65 assert expected_changes[key] == value |
| 66 |
| 67 |
| 68 def test_missing_bookmark(config): |
| 69 config.revision = 'foo' |
| 70 config.type = 'type' |
| 71 try: |
| 72 createNightlies.NightlyBuild(config) |
| 73 except CalledProcessError as e: |
| 74 assert e.returncode == 255 |
OLD | NEW |