| Index: sitescripts/extensions/test/test_createNightlies.py |
| =================================================================== |
| --- a/sitescripts/extensions/test/test_createNightlies.py |
| +++ b/sitescripts/extensions/test/test_createNightlies.py |
| @@ -7,32 +7,71 @@ |
| # |
| # Adblock Plus is distributed in the hope that it will be useful, |
| # 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/>. |
| +import os |
| +from subprocess import CalledProcessError |
| -"""Tests for create nightlies script.""" |
| import pytest |
| from sitescripts.extensions.bin import createNightlies |
| from sitescripts.utils import get_config |
| -@pytest.fixture() |
| -def config(hg_dir): |
| +@pytest.fixture(scope='session') |
| +def nightlydir(hg_dir): |
| + return hg_dir.join('adblockplusnightly') |
| + |
| + |
| +@pytest.fixture(scope='session') |
| +def config(hg_dir, nightlydir): |
| + """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 = nightlydir.strpath |
| return config |
| -@pytest.fixture() |
| +@pytest.fixture(scope='session') |
| def nightlybuild(config): |
| return createNightlies.NightlyBuild(config) |
| def test_nightly_object_bookmark(nightlybuild): |
| assert nightlybuild.config.revision == 'safari' |
| + |
| + |
| +def test_current_revision(nightlybuild): |
| + # This inline hash is for the expected revision of the safari bookmark rev |
|
Vasily Kuznetsov
2016/11/21 12:21:45
I think this comment could be improved a bit. We s
Jon Sonesen
2016/11/21 17:00:07
Done.
|
| + assert nightlybuild.revision == '1291590ddd0f' |
| + |
| + |
| +def test_copy_repository(nightlybuild, nightlydir): |
| + nightlybuild.copyRepository() |
| + assert os.listdir(nightlybuild.tempdir) == ['.hg', 'README.txt'] |
| + |
| + |
| +def test_get_changes(nightlybuild, nightlydir): |
| + # The bookmark 'safari' contains only 2 revisions |
| + # default contains 51 so here we ensure that erroneous changes |
| + # are not returned |
| + for change in nightlybuild.getChanges(): |
| + assert change['revision'] < '2' |
| + |
| + nightlybuild.config.revision = 'default' |
| + for change in nightlybuild.getChanges(): |
| + assert change['revision'] > '1' |
| + |
| + |
| +def test_missing_bookmark(config): |
| + config.revision = 'foo' |
| + config.type = 'type' |
| + try: |
| + createNightlies.NightlyBuild(config) |
| + except CalledProcessError as e: |
| + assert e.returncode == 255 |