summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozversion/tests/test_b2g.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/mozbase/mozversion/tests/test_b2g.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/mozbase/mozversion/tests/test_b2g.py')
-rw-r--r--testing/mozbase/mozversion/tests/test_b2g.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/testing/mozbase/mozversion/tests/test_b2g.py b/testing/mozbase/mozversion/tests/test_b2g.py
new file mode 100644
index 000000000..09e0eb09e
--- /dev/null
+++ b/testing/mozbase/mozversion/tests/test_b2g.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+import tempfile
+import unittest
+import zipfile
+
+import mozfile
+from mozversion import get_version, errors
+
+
+class SourcesTest(unittest.TestCase):
+ """test getting version information from a sources xml"""
+
+ def setUp(self):
+ self.tempdir = tempfile.mkdtemp()
+
+ self.binary = os.path.join(self.tempdir, 'binary')
+ with open(self.binary, 'w') as f:
+ f.write('foobar')
+
+ with open(os.path.join(self.tempdir, 'application.ini'), 'w') as f:
+ f.writelines("""[App]\nName = B2G\n""")
+
+ with open(os.path.join(self.tempdir, 'platform.ini'), 'w') as f:
+ f.write('[Build]\nBuildID = PlatformBuildID\n')
+
+ def tearDown(self):
+ mozfile.remove(self.tempdir)
+
+ def _create_zip(self, revision=None, date=None):
+ zip_path = os.path.join(
+ self.tempdir, 'gaia', 'profile', 'webapps',
+ 'settings.gaiamobile.org', 'application.zip')
+ os.makedirs(os.path.dirname(zip_path))
+ app_zip = zipfile.ZipFile(zip_path, 'w')
+ if revision or date:
+ app_zip.writestr('resources/gaia_commit.txt',
+ '%s\n%s' % (revision, date))
+ app_zip.close()
+
+ def test_gaia_commit(self):
+ revision, date = ('a' * 40, 'date')
+ self._create_zip(revision, date)
+ v = get_version(self.binary)
+ self.assertEqual(v.get('gaia_changeset'), revision)
+ self.assertEqual(v.get('gaia_date'), date)
+
+ def test_invalid_gaia_commit(self):
+ revision, date = ('a' * 41, 'date')
+ self._create_zip(revision, date)
+ v = get_version(self.binary)
+ self.assertIsNone(v.get('gaia_changeset'))
+ self.assertEqual(v.get('gaia_date'), date)
+
+ def test_missing_zip_file(self):
+ v = get_version(self.binary)
+ self.assertIsNone(v.get('gaia_changeset'))
+ self.assertIsNone(v.get('gaia_date'))
+
+ def test_missing_gaia_commit(self):
+ self._create_zip()
+ v = get_version(self.binary)
+ self.assertIsNone(v.get('gaia_changeset'))
+ self.assertIsNone(v.get('gaia_date'))
+
+ def test_b2g_fallback_when_no_binary(self):
+ self.assertRaises(errors.RemoteAppNotFoundError, get_version)
+
+if __name__ == '__main__':
+ unittest.main()