Example #1
0
    def test_discover(self):
        # Test: Mocking no services configured
        ci_discoverer_mock = CiDiscoverer()
        ci_discoverer_mock.services = None

        self.assertRaises(Exception, ci_discoverer_mock.discover, path='')

        # Test: Project with Travis CI
        self.assertTrue(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'squib')
        ))

        # Test: Project with AppVeyor
        self.assertTrue(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'grunt')
        ))

        # Test: Project with both Travis CI and AppVeyor
        self.assertTrue(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'grunt')
        ))

        # Test: Project with no CI (when these tests were written)
        self.assertFalse(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'django')
        ))
Example #2
0
def ci():
    os.chdir(root_directory)
    ci_discoverer = CiDiscoverer()
    try:
        os.chdir(root_directory)
        result = ci_discoverer.discover(repo_path+repoName)
        if(result == True):
            val = (str(int(result)),repo_id)
            QUERY = '''UPDATE `repoquester_results` SET `continuous_integration`=? WHERE `repo_id`=?'''
            try:
                os.chdir(root_directory)
                conn = sqlite3.connect('repo_quester.db',timeout=180)
                conn.execute(QUERY,val)
                conn.commit()
                print('CI: ',result)
                conn.close()
            except Exception as ex:
                print(ex)
                os.chdir(root_directory)
                conn = sqlite3.connect('repo_quester.db',timeout=180)
                conn.execute(QUERY,val)
                conn.commit()
                print('CI: ',result,' >> trying again.. ok')
                conn.close()
    except Exception as ex:
        print(ex)
Example #3
0
class CiDiscovererTestCase(unittest.TestCase):
    def setUp(self):
        self.ci_discoverer = CiDiscoverer()

    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_discover(self):
        # Test: Mocking no services configured
        ci_discoverer_mock = CiDiscoverer()
        ci_discoverer_mock.services = None

        self.assertRaises(Exception, ci_discoverer_mock.discover, path='')

        # Test: Project with Travis CI
        self.assertTrue(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'squib')
        ))

        # Test: Project with AppVeyor
        self.assertTrue(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'grunt')
        ))

        # Test: Project with both Travis CI and AppVeyor
        self.assertTrue(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'grunt')
        ))

        # Test: Project with no CI (when these tests were written)
        self.assertFalse(self.ci_discoverer.discover(
            os.path.join(REPOS_PATH, 'django')
        ))

    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_travis(self):
        # Test: Project with Travis CI
        self.assertTrue(self.ci_discoverer.__travis__(
            os.path.join(REPOS_PATH, 'squib')
        ))

        # Test: Project with no Travis CI
        self.assertFalse(self.ci_discoverer.__travis__(
            os.path.join(REPOS_PATH, 'django')
        ))

    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_appveyor(self):
        # Test: Project with AppVeyor CI
        self.assertTrue(self.ci_discoverer.__appveyor__(
            os.path.join(REPOS_PATH, 'grunt')
        ))

        # Test: Project with no AppVeyor CI
        self.assertFalse(self.ci_discoverer.__appveyor__(
            os.path.join(REPOS_PATH, 'squib')
        ))
Example #4
0
    def test_discover(self):
        # Test: Mocking no services configured
        ci_discoverer_mock = CiDiscoverer()
        ci_discoverer_mock.services = None

        self.assertRaises(Exception, ci_discoverer_mock.discover, path='')

        # Test: Project with Travis CI
        self.assertTrue(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'squib')))

        # Test: Project with AppVeyor
        self.assertTrue(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'grunt')))

        # Test: Project with both Travis CI and AppVeyor
        self.assertTrue(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'grunt')))

        # Test: Project with no CI (when these tests were written)
        self.assertFalse(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'django')))
Example #5
0
class CiDiscovererTestCase(unittest.TestCase):
    def setUp(self):
        self.ci_discoverer = CiDiscoverer()

    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_discover(self):
        # Test: Mocking no services configured
        ci_discoverer_mock = CiDiscoverer()
        ci_discoverer_mock.services = None

        self.assertRaises(Exception, ci_discoverer_mock.discover, path='')

        # Test: Project with Travis CI
        self.assertTrue(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'squib')))

        # Test: Project with AppVeyor
        self.assertTrue(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'grunt')))

        # Test: Project with both Travis CI and AppVeyor
        self.assertTrue(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'grunt')))

        # Test: Project with no CI (when these tests were written)
        self.assertFalse(
            self.ci_discoverer.discover(os.path.join(REPOS_PATH, 'django')))

    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_travis(self):
        # Test: Project with Travis CI
        self.assertTrue(
            self.ci_discoverer.__travis__(os.path.join(REPOS_PATH, 'squib')))

        # Test: Project with no Travis CI
        self.assertFalse(
            self.ci_discoverer.__travis__(os.path.join(REPOS_PATH, 'django')))

    @unittest.skipIf(not os.path.exists(REPOS_PATH), 'setup.sh not run.')
    def test_appveyor(self):
        # Test: Project with AppVeyor CI
        self.assertTrue(
            self.ci_discoverer.__appveyor__(os.path.join(REPOS_PATH, 'grunt')))

        # Test: Project with no AppVeyor CI
        self.assertFalse(
            self.ci_discoverer.__appveyor__(os.path.join(REPOS_PATH, 'squib')))
Example #6
0
import os
import sys

from attributes.continuous_integration.discoverer import CiDiscoverer

ci_discoverer = CiDiscoverer()


def run(project_id, repo_path, cursor, **options):
    result = ci_discoverer.discover(repo_path)
    return (int(result), result)


if __name__ == '__main__':
    print('Attribute plugins are not meant to be executed directly.')
    sys.exit(1)
Example #7
0
 def setUp(self):
     self.ci_discoverer = CiDiscoverer()
Example #8
0
 def setUp(self):
     self.ci_discoverer = CiDiscoverer()