Ejemplo n.º 1
0
    def test_cluster_numbers(self, tmp_clustered_files):
        # Arrange
        tmpdir = tmp_clustered_files[0]
        repos = tmp_clustered_files[1]
        test_pubs = BaseTestCase.get_test_publications()

        # Act
        Cluster().run(tmpdir)
        files = Base.get_files(tmpdir, include_clustered_files=True)

        # Assert
        # TODO: This assertion is anti-pattern; must be re-implemented in a much better way.
        for file in files:
            publications = Base.get_publications(file)

            checked = False
            for idx, row in publications.iterrows():
                for test_pub in test_pubs:
                    for idx2, row2 in test_pub[0].iterrows():
                        if row.get("Tools") == row2.get("Tools"):
                            assert row.get(
                                CLUSTER_NAME_COLUMN_LABEL) == row2.get(
                                    CLUSTER_NAME_COLUMN_LABEL)
                            checked = True

            assert checked == True
Ejemplo n.º 2
0
 def __init__(self):
     Base.__init__(self)
     self.level_spawn = 0
     self.player_death_msg = ''
     self.monster_death_msg = ''
     self.name = ''
     self.exp = 0
Ejemplo n.º 3
0
    def __init__(self, config_object):
        Base.__init__(self, config_object)

        ips_data = self.config_object.get_node_by_attr("name", "ips")

        self.dockerSubnetIpRange = ips_data.find(
            'dockerSubnetIpRange').text.replace("/", "\/")
Ejemplo n.º 4
0
 def __init__(self):
     # starting values
     Base.__init__(self)
     self.max_stats = {'health': 100, 'attack': 10, 'defense': 1, 'mana': 5}
     self.curr_stats = copy.copy(self.max_stats)
     self.skills = [StrongAttack()]
     self.level = 1
     self.to_next_level = 0
Ejemplo n.º 5
0
 def __init__(self, hostname, username, password):
     '''
     Constructor
     '''        
     self._hostname = hostname
     self._username = username
     self._password = password
     Base.__init__(self, SSH(hostname, username, password))
     self._eth_if_list = None
Ejemplo n.º 6
0
    def test_get_clustered_files(self, tmpdir):
        """
        Asserts if the `get_files` method reads only **clustered** files 
        when its flag is set (i.e., those with the cluster postfix).

        For instance, from a directory as the following, it should read 
        only `file_1_clustered.csv`:

        ├─── file_1.csv
        ├─── file_2.csv
        ├─── file_1_clustered.csv
        └─── file_3.txt

        :type  tmpdir:  string
        :param tmpdir:  The ‘tmpdir’ fixture is a py.path.local object
                        which will provide a temporary directory unique 
                        to the test invocation.
        """
        x = "content"
        for i in range(CSV_FILES_COUNT):
            tmpdir.join(f"file_{i}{CLUSTERED_FILENAME_POSFIX}.csv").write(x)
        tmpdir.join(f"file_{i}.csv").write(x)
        tmpdir.join(f"file_n.txt").write(x)

        # Act
        files = Base.get_files(tmpdir, include_clustered_files=True)

        # Assert
        assert len(files) == CSV_FILES_COUNT
        # checks if files are returned with their absolute path.
        for file in files:
            assert os.path.isabs(file) == True
Ejemplo n.º 7
0
    def test_get_vectors(self, test_publications):
        """
        This test asserts if various vectors are correctly extracted 
        from a given dataframe of publications (which represents a
        repository). For instance, extract from the dataframe the 
        citations a publication received before its tool was added 
        to the repository.
        """
        # Arrange
        input = test_publications[0]
        expected = test_publications[1]

        # Act
        citations, pre, post, sums, avg_pre, avg_post, deltas = Base.get_vectors(
            input)

        # Assert
        assert BaseTestCase.assert_lists_equal(citations,
                                               expected["citations"])
        assert BaseTestCase.assert_lists_equal(pre, expected["pre"])
        assert BaseTestCase.assert_lists_equal(post, expected["post"])
        assert BaseTestCase.assert_lists_equal(sums, expected["sums"])
        assert BaseTestCase.assert_lists_equal(avg_pre, expected["avg_pre"])
        assert BaseTestCase.assert_lists_equal(avg_post, expected["avg_post"])
        assert BaseTestCase.assert_lists_equal(deltas, expected["deltas"])
Ejemplo n.º 8
0
    def __init__(self, config_object):
        Base.__init__(self, config_object)

        ips_data = self.config_object.get_node_by_attr("name", "ips")

        self.serviceClusterIpRange = ips_data.find(
            'serviceClusterIpRange').text.replace("/", "\/")
        self.serviceClusterGatewayIp = ips_data.find(
            'serviceClusterGatewayIp').text
        self.serviceClusterDnsIp = ips_data.find('serviceClusterDnsIp').text
        self.podClusterIpRange = ips_data.find(
            'podClusterIpRange').text.replace("/", "\/")

        node_data = self.node_object.get_node_by_attr("name", "proxy")
        self.proxy_host = node_data.find('hostname').text
        self.proxy_port = node_data.find('port').text
Ejemplo n.º 9
0
    def test_get_repo_name(self, input, expected):
        """
        Asserts if the `get_repo_name` extracts repository name 
        from a given filename.
        """

        # Arrange, Act, Assert
        assert expected == Base.get_repo_name(input)
Ejemplo n.º 10
0
    def test_get_clusters(self, clustered_files):
        """
        clustered_files is set using clustered_files fixture from TestsBase.

        TODO: modify test so that it runs for every file in clustered files. 
        """
        # Arrange
        filename = clustered_files[0]

        # Act
        clusters = Base.get_clusters(filename)

        # Assert
        assert len(clusters.groups) == TEST_DATA_CLUSTERS
Ejemplo n.º 11
0
    def test_get_sorted_clusters(self, test_publications):

        # Arrange
        input = test_publications[0].groupby(CLUSTER_NAME_COLUMN_LABEL)
        expected = test_publications[1]
        exp_mapping = expected["cluster_avg"]
        exp_sorted_avg = sorted(exp_mapping.values())

        # Act
        mapping, _, sorted_avg = Base.get_sorted_clusters(input)

        # Assert
        assert BaseTestCase.assert_lists_equal(sorted_avg, exp_sorted_avg)
        assert BaseTestCase.assert_lists_equal(list(mapping.keys()),
                                               list(exp_mapping.keys()))
Ejemplo n.º 12
0
    def test_get_citations(self, test_publications):
        """
        Asserts a correct selection of the headers of the columns 
        containing citation count before and after a tool was added
        to the repository.
        """
        # Arrange
        input = test_publications[0]

        # Act
        pre, post = Base.get_citations_headers(input)

        # Assert
        assert len(pre) == 2
        assert len(post) == 3
Ejemplo n.º 13
0
    def test_ttest_delta(self, tmp_clustered_files):
        # Arrange
        tmpdir, inputs = tmp_clustered_files

        input_files = [x["filename"] for x in inputs]
        exp_avg_pre = [x["exp_values"]["avg_sum_pre"] for x in inputs]
        exp_avg_post = [x["exp_values"]["avg_sum_post"] for x in inputs]
        output_file = os.path.join(tmpdir, "test_ttest_delta_output.csv")

        # Pre-act Assert
        # The output file should not exist before the test runs.
        assert os.path.exists(output_file) == False

        # Act
        TTest().ttest_delta(input_files, output_file)

        # Assert
        assert os.path.exists(output_file)

        output_info = Base.get_publications(output_file)

        # Check if files have header
        assert BaseTestCase.assert_str_list_equal(list(output_info), TTest.TTEST_HEADER)

        # check the value of avg pre citations
        assert BaseTestCase.assert_lists_equal(output_info["Average Pre Citations"], exp_avg_pre)

        # check the value of avg post citations
        assert BaseTestCase.assert_lists_equal(output_info["Average Post Citations"], exp_avg_post)

        # Check if the values exist and are not 0.0 or NaN;
        # the correctness of their values is asserted via other tests.
        for column in output_info:
            if column in ["Repository", "Interpretation", "Growth"]:
                continue

            assert output_info[column].dtype == 'float64'
            for cell in output_info[column]:
                assert cell > 0.0
                assert not math.isnan(cell)
                assert not math.isinf(cell)
Ejemplo n.º 14
0
Archivo: map.py Proyecto: veeneck/Otto
 def __init__(self):
     Base.__init__(self)
Ejemplo n.º 15
0
def _logout(driver):
    base = Base(driver)
    # driver.get(host+"/disk/home?")
    base.click(loc_logout)
Ejemplo n.º 16
0
def _logout_result(driver):
    base = Base(driver)
    base.assert_is_title("百度网盘")
Ejemplo n.º 17
0
def _login_result(driver):
    base = Base(driver)
    base.assert_element_is_display(loc_login_success)
Ejemplo n.º 18
0
def _login(driver,username="******",psw="Qaz123456!"):
    base = Base(driver)
    # driver.get(host)  ## 在这边在写一次打开网址,会导致运行脚本时多次打开空白网页
    base.send_words(loc_userName,username)
    base.send_words(loc_psw,psw)
    base.click(loc_submit_btn)
Ejemplo n.º 19
0
Archivo: main.py Proyecto: veeneck/Otto
 def __init__(self):
     Base.__init__(self)
     pygame.init()
     self.screen = pygame.display.set_mode([1024, 768])
Ejemplo n.º 20
0
    def __init__(self):
        Base(Action, self).__init__(name='action', version='1.0')

        self._debug = False
        self._data = [
            'onafterprint',
            'onbeforeprint',
            'onbeforeunload',
            'onerror',
            'onhaschange',
            'onload',
            'onmessage',
            'onoffline',
            'ononline',
            'onpagehide',
            'onpageshow',
            'onpopstate',
            'onredo',
            'onresize',
            'onstorage',
            'onundo',
            'onunload',
            'onblur',
            'onchange',
            'oncontextmenu',
            'onfocus',
            'onformchange',
            'onforminput',
            'oninput',
            'oninvalid',
            'onreset',
            'onselect',
            'onsubmit',
            'onkeydown',
            'onkeypress',
            'onkeyup',
            'onclick',
            'ondblclick',
            'ondrag',
            'ondragend',
            'ondragenter',
            'ondragleave',
            'ondragover',
            'ondragstart',
            'ondrop',
            'onmousedown',
            'onmousemove',
            'onmouseout',
            'onmouseover',
            'onmouseup',
            'onmousewheel',
            'onscroll',
            'onabort',
            'oncanplay',
            'oncanplaythrough',
            'ondurationchange',
            'onemptied',
            'onended',
            'onerror',
            'onloadeddata',
            'onloadedmetadata',
            'onloadstart',
            'onpause',
            'onplay',
            'onplaying',
            'onprogress',
            'onratechange',
            'onreadystatechange',
            'onseeked',
            'onseeking',
            'onstalled',
            'onsuspend',
            'ontimeupdate',
            'onvolumechange',
            'onwaiting',
        ]
Ejemplo n.º 21
0
Archivo: fw.py Proyecto: huhe56/nj-snic
 def __init__(self, ssh):
     '''
     Constructor
     '''
     Base.__init__(self, ssh)
Ejemplo n.º 22
0
 def __init__(self, config_object):
     Base.__init__(self, config_object)
Ejemplo n.º 23
0
def _login(driver, user, psw):
    mgtv = Base(driver)
    driver.get("https://www.youku.com")
    mgtv.click(loc_to_user_login_path)
    mgtv.send_words(loc_to_user_inputbox, user)
    mgtv.send_words(loc_to_psw_inputbox, psw)
    mgtv.click(loc_to_agree)
    mgtv.click(loc_to_login_btn)