<commit_before>from __future__ import absolute_import
import unittest

from sdcm.utils.version_utils import get_branch_version_from_list, get_branch_version_from_repo, get_branch_version, is_enterprise

# pylint: disable=invalid-name

DEB_URL = 'https://s3.amazonaws.com/downloads.scylladb.com/enterprise/deb/unstable/stretch/'\
          '9f724fedb93b4734fcfaec1156806921ff46e956-2bdfa9f7ef592edaf15e028faf3b7f695f39ebc1'\
          '-525a0255f73d454f8f97f32b8bdd71c8dec35d3d/68/scylladb-2019.1/scylla.list'
RPM_URL = 'https://s3.amazonaws.com/downloads.scylladb.com/enterprise/rpm/unstable/centos/'\
          '9f724fedb93b4734fcfaec1156806921ff46e956-2bdfa9f7ef592edaf15e028faf3b7f695f39ebc1'\
          '-525a0255f73d454f8f97f32b8bdd71c8dec35d3d-a6b2b2355c666b1893f702a587287da978aeec22/71/scylla.repo'

BROKEN_URL = 'https://www.google.com'


class TestVersionUtils(unittest.TestCase):
    def test_01_get_branch_version_from_list(self):
        self.assertEqual(get_branch_version_from_list(DEB_URL), '2019.1.1')

    def test_02_get_branch_version_from_repo(self):
        self.assertEqual(get_branch_version_from_repo(RPM_URL), '2019.1.1')

    def test_03_get_branch_version(self):
        self.assertEqual(get_branch_version(RPM_URL), '2019.1.1')
        self.assertEqual(get_branch_version(DEB_URL), '2019.1.1')

    def test_04_get_branch_version_failed(self):
        self.assertRaisesRegex(ValueError, "url isn't a correct", get_branch_version, BROKEN_URL)
        self.assertRaisesRegex(ValueError, "url isn't a correct", get_branch_version_from_list, BROKEN_URL)
        self.assertRaisesRegex(ValueError, "url isn't a correct", get_branch_version_from_repo, BROKEN_URL)

    def test_05_is_enterprise(self):
        self.assertEqual(is_enterprise('2019.1.1'), True)
        self.assertEqual(is_enterprise('2018'), True)
        self.assertEqual(is_enterprise('3.1'), False)
        self.assertEqual(is_enterprise('2.2'), False)<commit_msg>add tmp repo to unittest of get_branch_version<commit_after>from __future__ import absolute_import
import unittest

from sdcm.utils.version_utils import get_branch_version_from_list, get_branch_version_from_repo, get_branch_version, is_enterprise

# pylint: disable=invalid-name

DEB_URL = 'https://s3.amazonaws.com/downloads.scylladb.com/enterprise/deb/unstable/stretch/'\
          '9f724fedb93b4734fcfaec1156806921ff46e956-2bdfa9f7ef592edaf15e028faf3b7f695f39ebc1'\
          '-525a0255f73d454f8f97f32b8bdd71c8dec35d3d/68/scylladb-2019.1/scylla.list'
RPM_URL = 'https://s3.amazonaws.com/downloads.scylladb.com/enterprise/rpm/unstable/centos/'\
          '9f724fedb93b4734fcfaec1156806921ff46e956-2bdfa9f7ef592edaf15e028faf3b7f695f39ebc1'\
          '-525a0255f73d454f8f97f32b8bdd71c8dec35d3d-a6b2b2355c666b1893f702a587287da978aeec22/71/scylla.repo'

ISSUE_5288_RPM_URL = 'http://scratch.scylladb.com/amos/yum_repos/master/piotrj_issue5288_v3/scylla.repo'

BROKEN_URL = 'https://www.google.com'


class TestVersionUtils(unittest.TestCase):
    def test_01_get_branch_version_from_list(self):
        self.assertEqual(get_branch_version_from_list(DEB_URL), '2019.1.1')

    def test_02_get_branch_version_from_repo(self):
        self.assertEqual(get_branch_version_from_repo(RPM_URL), '2019.1.1')
        self.assertEqual(get_branch_version_from_repo(ISSUE_5288_RPM_URL), '666.development')

    def test_03_get_branch_version(self):
        self.assertEqual(get_branch_version(RPM_URL), '2019.1.1')
        self.assertEqual(get_branch_version(DEB_URL), '2019.1.1')

    def test_04_get_branch_version_failed(self):
        self.assertRaisesRegex(ValueError, "url isn't a correct", get_branch_version, BROKEN_URL)
        self.assertRaisesRegex(ValueError, "url isn't a correct", get_branch_version_from_list, BROKEN_URL)
        self.assertRaisesRegex(ValueError, "url isn't a correct", get_branch_version_from_repo, BROKEN_URL)

    def test_05_is_enterprise(self):
        self.assertEqual(is_enterprise('2019.1.1'), True)
        self.assertEqual(is_enterprise('2018'), True)
        self.assertEqual(is_enterprise('3.1'), False)
        self.assertEqual(is_enterprise('2.2'), False)
        self.assertEqual(is_enterprise('666.development'), False)
{'fraction_non_alphanumeric': 0.10258845879838518, 'fraction_numerical': 0.10995013061030634, 'mean_word_length': 5.372163388804841, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6180034', 'n_tokens_mistral': 1861, 'n_tokens_neox': 1619, 'n_words': 159}