コード例 #1
0
ファイル: test_pt5.py プロジェクト: Tayxyz/Python-QtPy5--UI
    def singlesend(self):
        cmd_text = self.textcombox3.currentText()
        self.label_showresult.clear()
        self.label_showmax.setText('')
        self.label_showmin.setText('')
        self.label_showmean.setText('')

        if self.bg.checkedId() != -1:
            try:
                t = Fixture().senddir(cmd_text)
                print(t)
                num_value = re.compile('[+-][0-9.]+[0-9]+[E|e|^][+-][0-9]+')
                result = num_value.match(t)
                if t.startswith('Keysight'):
                    self.label_showresult.appendPlainText(t)
                    return

                if result.group(0):
                    text = self.changeformat(t) + self.unit
                    self.label_showresult.appendPlainText(text)
            except Exception as e:
                self.label_showresult.appendPlainText(str(Exception) + str(e))

        elif self.bg.checkedId() == -1:
            QMessageBox.information(self, '提示',
                                    'Need to choose the testing model',
                                    QMessageBox.Ok)
コード例 #2
0
ファイル: test_continue.py プロジェクト: einmalfel/git-aflow
    def test_unfinish(self):
        Fixture.from_scheme("""1:
                               s:-a1
                               d:-a1-e1-b1-c1-B1-b1-B1-b1
                               a:-1a
                               b:-a1-e1-1b
                               c:----------1c
                               e:----1e""").actualize()
        self.assert_aflow_dies_with(
            "1/a_v1 was previously merged in 1/staging, so it's impossible to "
            "unfinish it.", 'continue', '-u', 'a')
        dev_head = misc.rev_parse('1/develop')
        self.assert_aflow_dies_with(
            'Failed to continue 1/e_v1. It is merged in 1/b_v1 which was later '
            'merged in 1/develop. 1/develop reset back to ' + dev_head + '.',
            'continue', '-u', 'e')
        self.assert_aflow_returns_0(
            '1/b_v1 created and checked out. Use "git af topic finish" to '
            'merge new revision of topic into develop', 'continue', '-u', 'b')
        self.assert_aflow_returns_0(
            """Using "End User Feature" as default topic type.
1/b_v1 merged into 1/develop successfully.
Branch 1/b_v1 deleted.""",
            'finish')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
            1:-
            s:-a1
            d:-a1-e1-c1-b1
            c:-1c
            e:-1e
            a:-1a
            b:-a1-e1-1b"""))
コード例 #3
0
ファイル: test_revert.py プロジェクト: einmalfel/git-aflow
 def test_upstream(self):
     Fixture.from_scheme("""1:-a1
                            s:-a1
                            d:-a1
                            a:-1a
                            2:-a2
                            s:-a2
                            d:-a2
                            a:-2a""").actualize()
     misc.checkout('1/staging')
     self.assert_aflow_dies_with(
         'Error: 1/a_v1 is merged in master. In git-aflow you cannot revert '
         'a topic until it is reverted from the upstream branch.',
         'revert', 'a')
     misc.checkout('1/develop')
     self.assert_aflow_dies_with(
         'Error: 1/a_v1 is merged in 1/staging. In git-aflow you cannot '
         'revert a topic until it is reverted from the upstream branch.',
         'revert', 'a')
     misc.checkout('2/staging')
     self.assert_aflow_dies_with(
         'Error: 2/a_v2 is merged in master. In git-aflow you cannot revert '
         'a topic until it is reverted from the upstream branch.',
         'revert', 'a')
     self.assert_aflow_returns_0(None, 'start', 'integration')
     self.assert_aflow_returns_0(None, 'merge', 'a')
     self.assert_aflow_returns_0('2/a_v2 reverted successfully.',
                                 'revert', 'a')
コード例 #4
0
async def load():
    # Init fixture array & node dict
    fixtures = []
    nodes = {}
    for dirpath, dirs, files in os.walk("./active/"):
        for filename in files:
            # Load config file
            fname = os.path.join(dirpath, filename)
            config = configparser.ConfigParser()
            config.read(fname)

            # Init fixtureconfig object
            fixtureconfig = {}

            # Load values from config to fixtureconfig
            # Needs to made prettier
            for key in config['position']:
                fixtureconfig[key] = float(config['position'][key])
            for key in config['channels']:
                fixtureconfig[key] = int(config['channels'][key])
            for key in config['location']:
                fixtureconfig[key] = float(config['location'][key])

            fixtureconfig['start_channel'] = int(
                config['DMX']['start_channel'])
            fixtureconfig['universe'] = int(config['DMX']['universe'])
            fixtureconfig['node_ip'] = config['DMX']['node_ip']

            fixtureconfig['prefer_tilt'] = config['misc'].getboolean(
                'prefer_tilt')
            fixtureconfig['default_fade_time'] = int(
                config['misc']['default_fade_time'])
            fixtureconfig['invert_tilt'] = config['misc'].getboolean(
                'invert_tilt')
            fixtureconfig['invert_pan'] = config['misc'].getboolean(
                'invert_pan')

            node_ip = fixtureconfig['node_ip']
            universe = fixtureconfig['universe']

            # Create node, universe and fixture objects
            if not node_ip in nodes:
                # Create new node if it doesn't exist
                nodeobj = ArtNetNode(node_ip, max_fps=44, refresh_every=5)
                await nodeobj.start()
                nodes[node_ip] = {'node': nodeobj, 'universes': {}}
            if not universe in nodes[node_ip]['universes']:
                # Create new universe if it doesn't exist
                nodeobj = nodes[node_ip]['node']
                universeobj = nodeobj.add_universe(universe)
                nodes[node_ip]['universes'][universe] = universeobj

            # Create fixture and init
            fixture = Fixture(fixtureconfig)
            fixture.start(nodes[node_ip]['universes'][universe])

            fixtures.append(fixture)
    return (fixtures, nodes)
コード例 #5
0
ファイル: test_continue.py プロジェクト: einmalfel/git-aflow
 def test_auto_name(self):
     Fixture.from_scheme("""1:
                            d:-a1
                            a:-1a""").actualize()
     misc.checkout('1/develop^2')
     self.assert_aflow_returns_0(
         '1/a_v2 created and checked out. Use "git af topic finish" to '
         'merge new revision of topic into develop',
         'continue')
コード例 #6
0
	def __init__(self):
		DATA.Readini()
		self.ll = localLog.LocalLog()
		self.sfis = SFIS.SFIS()
		self.fix = Fixture()


		self.windowname = DATA.WindowName
		self.id = 0
		self.ISNid_list = []
コード例 #7
0
ファイル: test_revert.py プロジェクト: einmalfel/git-aflow
 def test_checks(self):
     Fixture.from_scheme("""1:
                            d:-a1
                            a:-1a""").actualize()
     misc.checkout('1/develop')
     self.assert_aflow_dies_with('Error: topic a specified more than once',
                                 'revert', 'a', 'a_v1')
     self.assert_aflow_dies_with("Didn't found non-reverted merges of a_v2 "
                                 "in 1/develop", 'revert', 'a_v2')
     self.assert_aflow_dies_with("Didn't found non-reverted merges of b in "
                                 "1/develop", 'revert', 'b')
コード例 #8
0
ファイル: test_revert.py プロジェクト: einmalfel/git-aflow
 def test_unexpected_conflict(self):
     Fixture.from_scheme("""1:
                            d:-a1
                            a:-1a""").actualize()
     misc.checkout('1/develop')
     with open('a', 'w') as b:
         b.write('Does not matter')
     misc.add('a')
     commit.commit('No matter')
     self.assert_aflow_dies_with('Revert failed unexpectedly, aborting..',
                                 'revert', 'a')
コード例 #9
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_exclude_current(self):
        Fixture.from_scheme('''1:
                               d:-a1-------b1
                               b:----a1-1-
                               a:-1a''').actualize()

        # branch c is based on a, so a_v1 should be excluded from merge
        misc.checkout('1/a')
        branch.create('c')
        misc.checkout('c')
        self.assert_aflow_returns_0(
            'Using default topic source(s): develop' + os.linesep +
            '1/b_v1 merged successfully',
            'merge', '-d', 'b')
コード例 #10
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
 def test_unexpected_conflict(self):
     Fixture.from_scheme("""1:
                            a:-1a""").actualize()
     misc.checkout('1/develop')
     with open('a', 'w') as b:
         b.write('Does not matter')
     misc.add('a')
     commit.commit('No matter')
     misc.checkout('1/a_v1')
     self.assert_aflow_dies_with(
         'Using "End User Feature" as default topic type.' + os.linesep +
         'Merge of 1/a_v1 conflicted unexpectedly. Conflict detector gave '
         'false negative result. 1/develop reset.',
         'finish')
コード例 #11
0
 def setUp(self):
     mock_config_parser = configparser.ConfigParser()
     mock_os = mock.Mock()
     mock_config_parser["kong-apikey"] = {"apikey": "testing_api_key"}
     mock_config_parser.read = mock.MagicMock()
     mock_config_parser.ConfigParser = mock.MagicMock(
         return_value=mock_config_parser)
     mock_os.environ = {
         "kong_apikey_file": "secrets.ini"
     }
     sys.modules['configparser'] = mock_config_parser
     sys.modules['os'] = mock_os
     from fixture import Fixture
     self.subject = Fixture()
コード例 #12
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
    def test_update_for_prev_iter_topic(self):
        Fixture.from_scheme("""1:-a1
                               s:-a1
                               d:-a1
                               a:-1a
                               2:
                               d:-b1
                               b:-1b""").actualize()
        branch.create('2/a_v2', '2')
        misc.checkout('2/a_v2')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_returns_0(
            """Taking topic type from previous merge of 1/a_v1.
2/a_v2 merged into 2/develop successfully.
Branch 2/a_v2 deleted.""", 'finish')
コード例 #13
0
ファイル: test_continue.py プロジェクト: einmalfel/git-aflow
 def test_cross_iteration(self):
     Fixture.from_scheme("""1:-a1
                            s:-a1
                            d:-a1
                            a:-1a
                            2:""").actualize()
     misc.checkout('2/develop')
     self.assert_aflow_returns_0(
         '2/a_v2 created and checked out. Use "git af topic finish" to '
         'merge new revision of topic into develop', 'continue', 'a')
     commit.commit('No matter', allow_empty=True)
     self.assert_aflow_returns_0(None, 'finish')
     self.assert_aflow_dies_with(
         'Failed to find merges of b in 2 and previous iterations.',
         'continue', 'b')
     self.assert_aflow_returns_0(
         'Please, note that a_v2'
         ' is already present in other iteration(s), so changes you will '
         'make for this revision in current iteration should correspond to '
         'changes made for same revision in other iterations. You may '
         'also use "git af port" to bring commits of some revision from '
         'one iteration to another.' + os.linesep +
         '1/a_v2 created and checked out. Use "git af topic finish" to '
         'merge new revision of topic into develop',
         'continue', '1/a')
     misc.checkout('2/staging')
     self.assert_aflow_returns_0(None, 'merge', 'a')
     misc.checkout('master')
     self.assert_aflow_returns_0(None, 'merge', 'a')
     self.assert_aflow_returns_0(None, 'rebase', '-n', '3')
     self.assert_aflow_returns_0(
         '3/a_v3 created and checked out. Use "git af topic finish" to '
         'merge new revision of topic into develop',
         'continue', 'a')
     commit.commit('No matter', allow_empty=True)
     self.assert_aflow_returns_0(None, 'finish')
     self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
         1:-a1
         s:-a1
         d:-a1
         a:-1a
         2:-a2
         s:-a2
         d:-a2
         a:-2-
         3:
         d:-a3
         a:-3-"""))
コード例 #14
0
def transform_response(_json: dict) -> str:
    """Transform message format from sports db to lite version for display via API"""
    my_list = dict(_json).pop("results")
    converted_list = []
    for fix in my_list:
        converted_list.append(Fixture(fix))
    return json.dumps([f.dump() for f in converted_list])
コード例 #15
0
 def setUp(self):
   self.build_mvine = Mvine.build
   Mvine.build = Mock(return_value = True)
   self.cs = ConstraintSystem()
   self.cs._propagate_walk_strength = Mock(return_value = True)
   self.cs.collect_unenforced = Mock(return_value = True)
   self.f = Fixture()
コード例 #16
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
 def test_complex(self):
     Fixture.from_scheme("""1:
                            d:-a1-b1-a2-b2-c1
                            a:-1a-a--2A
                            b:-1b-a1-a2-2--c1
                            c:-a1-a2-b1-b2-1c""").actualize()
     self.assert_aflow_returns_0(None, 'checkout', 'b')
     commit.commit('No matter', allow_empty=True)
     self.assert_aflow_returns_0(None, 'finish')
     self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
         1:-
         s:-
         d:-a1-b1-a2-b2-c1-b3
         a:-1a-a--2A
         b:-1b-a1-a2-2--c1-3-
         c:-a1-a2-b1-b2-1c"""))
コード例 #17
0
 def addNewFixture(self):
     newIdNumber = len(self.fixtures)+1
     fixture = Fixture(self.graphicsView, newIdNumber);
     self.fixtures.append(fixture)
     self.fixtureChooser.addItem(str(len(self.fixtures)))
     self.fixtureChooser.setCurrentIndex(len(self.fixtures))
     self.chosen(len(self.fixtures))
コード例 #18
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
 def test_reverts(self):
     Fixture.from_scheme("""1:
                            d:-a1
                            a:-1a
                            b:-a1""").actualize()
     misc.checkout('1/b')
     self.assert_aflow_returns_0(None, 'revert', 'a')
     self.assert_aflow_dies_with(
         "Current topic contains reverts of topics from current iteration "
         "which is forbidden. Please rebase your topic excluding merges you "
         "don't like and try to finish it again.", 'finish')
     self.assert_aflow_returns_0(None, 'merge', 'a')
     self.assert_aflow_returns_0(None, 'revert', 'a')
     self.assert_aflow_dies_with(
         "Current topic contains reverts of topics from current iteration "
         "which is forbidden. Please rebase your topic excluding merges you "
         "don't like and try to finish it again.", 'finish')
コード例 #19
0
ファイル: test_revert.py プロジェクト: einmalfel/git-aflow
    def test_fake_merge(self):
        Fixture.from_scheme("""1:
                               s:-a1
                               d:-a1
                               a:-1a""").actualize()
        misc.checkout('1/staging')
        self.assert_aflow_returns_0('1/a_v1 reverted successfully.',
                                    'revert', 'a')
        self.assert_aflow_returns_0("""Using default topic source(s): develop
1/a_v1 merged successfully""", 'merge', 'a')
        self.assert_aflow_returns_0('1/a_v1 reverted successfully.',
                                    'revert', 'a')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
            1:-
            s:-a1-A1-a1-A1
            d:-a1
            a:-1a"""))
コード例 #20
0
ファイル: test_revert.py プロジェクト: einmalfel/git-aflow
    def test_versions(self):
        Fixture.from_scheme("""1:
                               d:-a1-b1-a2-c1-b2-a3
                               a:-1a-b1-2a-c1-b2-3a
                               b:-a1-1b-a2-c1-2b
                               c:-a1-b1-a2-1c""").actualize()
        misc.checkout('1/develop')
        self.assert_aflow_returns_0("""1/a_v3 reverted successfully.
1/b_v2 reverted successfully.
1/c_v1 reverted successfully.
1/a_v2 reverted successfully.""", 'revert', 'a_v2', '-d')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
            1:-
            s:-
            d:-a1-b1-a2-c1-b2-a3-A3-B2-C1-A2
            b:-a1-1b-a2-c1-2b
            a:-1a-b1-2a-c1-b2-3a
            c:-a1-b1-a2-1c"""))
コード例 #21
0
ファイル: test_continue.py プロジェクト: einmalfel/git-aflow
 def test_checks(self):
     Fixture.from_scheme("""1:
                            d:-a1
                            a:-1a""").actualize()
     misc.checkout('1/develop')
     self.assert_aflow_dies_with(
         'No topic name was specified, neither HEAD is pointing to '
         'last commit of some topic. Nothing to continue.',
         'continue')
     self.assert_aflow_returns_0(
         'Version suffix ignored.' + os.linesep +
         '1/a_v2 created and checked out. Use "git af topic finish" to ' +
         'merge new revision of topic into develop',
         'continue', 'a_v1')
     self.assert_aflow_dies_with(
         '1/a_v2 already exists. Use "git af checkout 1/a_v2" to continue '
         'your work on topic',
         'continue', 'a')
コード例 #22
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
    def test_refinish(self):
        Fixture.from_scheme("""1:
                               d:-a1
                               a:-1a""").actualize()

        misc.checkout('1/develop')
        commit.revert('HEAD', parent=1)
        branch.delete('1/a')
        self.assert_aflow_returns_0(None, 'checkout', 'a')
        self.assert_aflow_returns_0(
            'Assuming topic you are finishing is 1/a_v1.' + os.linesep +
            'Taking topic type from previous merge of 1/a_v1.' + os.linesep +
            '1/a_v1 merged into 1/develop successfully.',
            'finish')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
            1:
            d:-a1-A1-a1
            a:-1a"""))
コード例 #23
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_dependencies(self):
        Fixture.from_scheme('''1:
                               d:----a1-b1-a2-c1
                               a:-1a----b1-2c
                               b:-1b---------
                               c:----b1-a1-a2-1-''').actualize()

        misc.checkout('1/staging')
        self.assert_aflow_returns_0(None, 'merge', '-a')
        misc.checkout('master')
        self.assert_aflow_returns_0(None, 'merge', '-d', 'c')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme(
            '''1:----b1-a1-a2-c1
               s:----a1-b1-a2-c1
               d:----a1-b1-a2-c1
               a:-1a----b1-2c
               b:-1b---------
               c:----b1-a1-a2-1-'''))
コード例 #24
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
 def test_conflict_with_deps_first(self):
     Fixture.from_scheme("""1:
                            d:-a1-b1-c1-e1
                            a:-1a
                            b:-a1-1b
                            c:-a1----1c
                            e:-a1-------1e
                            """).actualize()
     self.assert_aflow_returns_0(None, 'start', 'f')
     with open('a', 'w') as a:
         a.write('Does not matter')
     misc.add('a')
     commit.commit('No matter')
     # bug isn't reproduced stably, but probably it fails on the first try
     for i in range(0, 5):
         self.assert_aflow_dies_with(
             'Finish failed because of conflicts between current '
             'topic and 1/a_v1 in file a',
             'finish')
コード例 #25
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
    def test_auto_version(self):
        Fixture.from_scheme("""1:
                               d:-a1
                               a:-1a-a-""").actualize()
        misc.checkout('1/a')
        self.assert_aflow_returns_0(
            """Using topic version 2 as default.
Taking topic type from previous merge of 1/a_v1.
1/a_v2 merged into 1/develop successfully.
Branch 1/a deleted.""",
            'finish')

        commit.revert('HEAD', 1)
        self.assert_aflow_returns_0(None, 'checkout', 'a')
        self.assert_aflow_returns_0(
            """Using version 2 of already merged revision with same head SHA.
Taking topic type from previous merge of 1/a_v2.
1/a_v2 merged into 1/develop successfully.""",
            'finish', '-n', 'a')
コード例 #26
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
 def test_subdirectory_conflict(self):
     Fixture.from_scheme("""1:
                            a:
                            b:""").actualize()
     misc.checkout('1/a')
     os.mkdir('subdir')
     with open('subdir/a', 'w') as a:
         a.write('A content')
     misc.add('subdir/a')
     commit.commit('No matter a')
     self.assert_aflow_returns_0(None, 'finish')
     misc.checkout('1/b')
     os.mkdir('subdir')
     with open('subdir/a', 'w') as a:
         a.write('B content')
     misc.add('subdir/a')
     commit.commit('No matter b')
     os.chdir('subdir')
     self.assert_aflow_dies_with(
         'Finish failed because of conflicts between current '
         'topic and 1/a_v1 in file subdir/a',
         'finish')
     os.chdir(misc.get_root_dir())
     misc.checkout('1/staging')
     self.assert_aflow_returns_0(None, 'merge', 'a')
     misc.checkout('master')
     self.assert_aflow_returns_0(None, 'merge', 'a')
     self.assert_aflow_returns_0(None, 'rebase', '-n', '2')
     self.assert_aflow_returns_0(None, 'continue', 'a')
     with open('subdir/a', 'w') as a:
         a.write('A new content')
     misc.add('subdir/a')
     commit.commit('No matter a2')
     self.assert_aflow_returns_0(None, 'finish')
     self.assert_aflow_returns_0(None, 'start', 'b')
     misc.rm('subdir', recursively=True)
     commit.commit('delete a')
     self.assert_aflow_dies_with(
         'Finish failed because of conflicts between current '
         'topic and 2/a_v2 in file subdir/a',
         'finish')
コード例 #27
0
ファイル: test_revert.py プロジェクト: einmalfel/git-aflow
    def test_dependents(self):
        Fixture.from_scheme("""1:
                               d:-a1-b1-c1
                               a:-1a
                               b:-a1-1b
                               c:-a1-b1-1c""").actualize()
        misc.checkout('1/develop')
        self.assert_aflow_dies_with(
            'Unable to revert 1/a_v1 since 1/c_v1 depends on it. '
            'Revert it first or use "git af revert -d" revert dependent '
            'topics automatically.', 'revert', 'a')
        self.assert_aflow_returns_0("""1/c_v1 reverted successfully.
1/b_v1 reverted successfully.
1/a_v1 reverted successfully.""", 'revert', 'a', '-d')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
            1:-
            d:-a1-b1-c1-C1-B1-A1
            b:-a1-1b
            a:-1a
            c:-a1-b1-1c"""))
        branch.reset('HEAD^^^')
        self.assert_aflow_returns_0("""1/c_v1 reverted successfully.
1/b_v1 reverted successfully.""", 'revert', 'b', 'c')
        self.assertEqual(Fixture.from_repo(), Fixture.from_scheme("""
            1:-
            d:-a1-b1-c1-C1-B1
            b:-a1-1b
            a:-1a
            c:-a1-b1-1c"""))
コード例 #28
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_conflict(self):
        Fixture.from_scheme('''1:
                               d:----b1-c1
                               b:-1b
                               a:-b-
                               c:-1c''').actualize()

        misc.checkout('1/a')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'Merge of 1/b_v1 failed. See conflicted files via "git status", '
            'resolve conflicts, add files to index ("git add") and do '
            '"git commit --no-edit" to finish the merge.' + os.linesep +
            'Alternatively, you may abort failed merge via "git merge --abort"',
            'merge', 'b')
        commit.abort_merge()

        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'Merge of 1/b_v1 failed. See conflicted files via "git status", '
            'resolve conflicts, add files to index ("git add") and do '
            '"git commit --no-edit" to finish the merge.' + os.linesep +
            'Then call "git af merge [topics]" again to merge remaining '
            'topics. Topics remaining to merge: 1/c_v1' + os.linesep +
            'Alternatively, you may abort failed merge via "git merge --abort"',
            'merge', 'b', 'c')
        commit.abort_merge()

        misc.checkout('1/develop')
        commit.merge('1/a')
        misc.add('b')
        commit.commit()
        misc.checkout('1/staging')
        self.assert_aflow_returns_0(None, 'merge', 'b')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'Merge of 1/a_v1 failed. Something went wrong, did not '
            'expect conflict there (1/staging). Please check carefully what '
            'you are doing. Merge aborted.',
            'merge', 'a')
コード例 #29
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_already_merged(self):
        Fixture.from_scheme('''1:
                               d:-a1-a2
                               a:-1a-2a
                               b:-a1-a2''').actualize()

        misc.checkout('1/b')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'Latest revision of a in sources is 1/a_v2. We already have it '
            'merged in 1/b. Skipping..' + os.linesep +
            'There is nothing to merge.',
            'merge', 'a')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'We already have this version of a_v2 in 1/b. Skipping..' +
            os.linesep + 'There is nothing to merge.',
            'merge', 'a_v2')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'There is nothing to merge.',
            'merge', '-a')
コード例 #30
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_description_type(self):
        Fixture.from_scheme('''1:
                               d:-a1
                               a:-1a''').actualize()
        # edit description/type
        misc.checkout('1/staging')
        self.assert_aflow_returns_0(
            None, 'merge', '-e', 'No matter.', '-D', 'a')
        self.assertEqual(commit.get_full_message('HEAD'),
                         """Merge branch '1/a_v1' into 1/staging

DEV
No matter.""")

        # use description/type from sources
        misc.checkout('master')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        self.assertEqual(commit.get_full_message('HEAD'),
                         """Merge branch '1/a_v1'

DEV
No matter.""")
コード例 #31
0
ファイル: test_list.py プロジェクト: einmalfel/git-aflow
    def test_filter(self):
        Fixture.from_scheme("""1:
                               d:-a1
                               a:-1a""").actualize()
        self.assert_aflow_returns_0(None, 'start', 'refactoring')
        commit.commit('No matter1', allow_empty=True)
        self.assert_aflow_returns_0(None, 'finish', '-D', 'Blah blah.')
        self.assert_aflow_returns_0(None, 'start', 'fix')
        commit.commit('No matter2', allow_empty=True)
        self.assert_aflow_returns_0(
            None, 'finish', '-F',
            'Very long description very long description very long description')
        self.assert_aflow_returns_0("""\
Using default topic source(s): develop
1/develop-----------Type |Ver| Description--------------------------------------
fix                  FIX | 1 | Very long description very long description ve...
refactoring          DEV | 1 | Blah blah.""", 'list', '-FD')
        self.assert_aflow_returns_0("""\
Using default topic source(s): develop
1/develop-----------Type |Ver| Description--------------------------------------
refactoring          DEV | 1 | Blah blah.
a                    EUF | 1 | N/A""", 'list', '-D', '--EUF')
コード例 #32
0
 def __init__(self, *args, **kwargs):
     super(MyGraphicsView, self).__init__()
     scene = QGraphicsScene(self)
     self.mainWindow = args[0]
     self.actFixture = Fixture(self)
     self.conf = loadconf()
     self.scene = scene
     scene.setItemIndexMethod(QGraphicsScene.NoIndex)
     scene.setSceneRect(0, 0, self.conf['x_max'], self.conf['y_max'])
     self.setScene(scene)
     self.setCacheMode(QGraphicsView.CacheBackground)
     self.setCacheMode(QGraphicsView.CacheNone)
     self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
     self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
     self.grabbed = None
     self.selected = None
     self.bgImage = None
     self.mainSprite = None
     self.zoom = 1
     self.zoomStep = 2  # used by menu commands
     self.zoomScale = 1  # used by mouse zoom
     self.signalZoomByMouse.connect(self.slotZoom, Qt.QueuedConnection)
     self.setTransformationAnchor(QGraphicsView.NoAnchor)
コード例 #33
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_update(self):
        Fixture.from_scheme('''1:
                               s:----a1-b1
                               d:----a1-b1-c1-a2-b2-c2-a3
                               a:-1a----2a-------b2-c2-3a
                               b:-1b----------a2-2b
                               c:-1c----------a2-b2-2c''').actualize()

        misc.checkout('1/staging')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'Merge failed. Topic 1/a_v3 depends on 1/c_v1. Try merge it first '
            'or use "git af merge -d" to merge dependencies automatically',
            'merge', '-u')
        self.assert_aflow_returns_0(None, 'merge', '-d', '-u')
        self.assertEqual(
            Fixture.from_repo(),
            Fixture.from_scheme("""1:-
                                   s:-a1-b1-a2-b2-c1-c2-a3
                                   d:-a1-b1-c1-a2-b2-c2-a3
                                   b:-1b-a1-a2-2b
                                   c:-1c-a1-a2-b1-b2-2c
                                   a:-1a-2a-b1-b2-c1-c2-3a"""))
コード例 #34
0
ファイル: test_list.py プロジェクト: einmalfel/git-aflow
    def test_sources(self):
        Fixture.from_scheme("""1:-a1
                               s:-a1
                               d:-a1
                               a:-1a
                               2:
                               d:-a2
                               a:-2a""").actualize()
        self.assert_aflow_returns_0("""\
master--------------Type |Ver| Description--------------------------------------
2/staging-----------Type |Ver| Description--------------------------------------
2/develop-----------Type |Ver| Description--------------------------------------
a                    EUF | 2 | N/A""", 'list', '-a')
        misc.checkout('2/staging')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        self.assert_aflow_returns_0("""\
Using default topic source(s): develop
2/develop-----------Type |Ver| Description--------------------------------------
a                    EUF | 2 | N/A""", 'list')
        self.assert_aflow_returns_0("""\
master--------------Type |Ver| Description--------------------------------------
1/develop-----------Type |Ver| Description--------------------------------------
a                    EUF | 1 | N/A""", 'list', 'master', '1/develop')
コード例 #35
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
    def test_preserve_description(self):
        Fixture.from_scheme("""1:-a1
                               s:-a1
                               d:-a1
                               a:-1a
                               2:""").actualize()
        branch.create('2/a_v2', '2')
        misc.checkout('2/a_v2')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_returns_0(
            """Taking topic type from previous merge of 1/a_v1.
2/a_v2 merged into 2/develop successfully.
Branch 2/a_v2 deleted.""",
            'finish', 'Some description')
        misc.checkout('2/staging')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        misc.checkout('master')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        self.assert_aflow_returns_0(None, 'continue', 'a')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_returns_0(None, 'finish', '-D', 'Other description')
        self.assert_aflow_returns_0(None, 'rebase', '-n', '3')
        self.assert_aflow_returns_0(None, 'continue', '3/a')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_returns_0(
            """Taking topic description from previous merge of 2/a_v3.
Taking topic type from previous merge of 2/a_v3.
3/a_v3 merged into 3/develop successfully.
Branch 3/a_v3 deleted.""",
            'finish')
        self.assertEqual(
            commit.get_full_message('HEAD'),
            """Merge branch '3/a_v3' into 3/develop

DEV
Other description""")
コード例 #36
0
ファイル: league.py プロジェクト: jamiestronach/FPL_Draft
    def add_result(self, player_id, gameweek, fixture_set, league):
        result = Fixture(player_id, gameweek, fixture_set)
        
        league.at[player_id, "GD"] = league["GD"][player_id] + result.team_score
        
        if result.outcome_points == 3:
            league.at[player_id, "Wins"] = league["Wins"][player_id] + 1
            league.at[player_id, "Points"] = league["Points"][player_id] + 3

        elif result.outcome_points == 1:
            league.at[player_id, "Draws"] = league["Draws"][player_id] + 1
            league.at[player_id, "Points"] = league["Points"][player_id] + 1
        
        elif result.outcome_points == 0:
            league.at[player_id, "Losses"] = league["Losses"][player_id] + 1

        return league
コード例 #37
0
 def __init__(self, *args, **kwargs):
     super(MyGraphicsView, self).__init__()
     scene = QGraphicsScene(self)
     self.mainWindow = args[0]
     self.actFixture = Fixture(self)
     self.conf = loadconf()
     self.scene = scene
     scene.setItemIndexMethod(QGraphicsScene.NoIndex)
     scene.setSceneRect(0, 0, self.conf['x_max'], self.conf['y_max'])
     self.setScene(scene)
     self.setCacheMode(QGraphicsView.CacheBackground)
     self.setCacheMode(QGraphicsView.CacheNone)
     self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
     self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
     self.grabbed = None
     self.selected = None
     self.bgImage = None
     self.mainSprite = None
     self.zoom = 1
     self.zoomStep = 2 # used by menu commands
     self.zoomScale = 1 # used by mouse zoom
     self.signalZoomByMouse.connect(self.slotZoom,Qt.QueuedConnection)
     self.setTransformationAnchor( QGraphicsView.NoAnchor )
コード例 #38
0
ファイル: week.py プロジェクト: laingbs/magic_octopus
    def __init__(self, fixture_data, start_index, teams):
       fixture_index = start_index
       self.table = Table(teams)
       self.fixtures = []
       self.number = int(start_index / 10.0)
       for i in range(start_index, start_index+10):
           current_fixture = Fixture()
           current_fixture.hteam = fixture_data[cst.HOME_TEAM][i]
           current_fixture.ateam = fixture_data[cst.AWAY_TEAM][i]
           current_fixture.hg = int(fixture_data[cst.HG][i])
           current_fixture.ag = int(fixture_data[cst.AG][i])

           self.fixtures.append(current_fixture)
           self.table.add_fixture(current_fixture)

       if len(self.fixtures) != 10:
           print('Error - should be 10 fixtures, there are {0}'
               .format(len(self.fixtures)))
           return
コード例 #39
0
ファイル: test_pt5.py プロジェクト: Tayxyz/Python-QtPy5--UI
 def sendcmd(self, cmd):
     try:
         text = Fixture().senddir(cmd)
         return text
     except Exception as e:
         return str(Exception) + str(e)
コード例 #40
0
 def __init__(self, name, weight, position, person_in_charge):
     Fixture.__init__(self, name, weight, position)
     self._person_in_charge = person_in_charge
コード例 #41
0
class TestFixture(TestCase):
    def setUp(self):
        mock_config_parser = configparser.ConfigParser()
        mock_os = mock.Mock()
        mock_config_parser["kong-apikey"] = {"apikey": "testing_api_key"}
        mock_config_parser.read = mock.MagicMock()
        mock_config_parser.ConfigParser = mock.MagicMock(
            return_value=mock_config_parser)
        mock_os.environ = {
            "kong_apikey_file": "secrets.ini"
        }
        sys.modules['configparser'] = mock_config_parser
        sys.modules['os'] = mock_os
        from fixture import Fixture
        self.subject = Fixture()

    @responses.activate
    def test_run_create_all_succeed(self):
        responses.add(responses.GET,
                      'http://kong:8001/consumers/admin/key-auth',
                      status=404)
        responses.add(responses.POST, 'http://kong:8001/consumers', status=201)
        responses.add(responses.POST,
                      'http://kong:8001/consumers/admin/key-auth',
                      status=201)
        responses.add(responses.GET,
                      'http://kong:8001/services/adminApi',
                      status=404)
        responses.add(responses.POST, 'http://kong:8001/services', status=201)
        responses.add(responses.GET,
                      'http://kong:8001/services/adminApi/routes/adminApi',
                      status=404)
        responses.add(responses.POST,
                      'http://kong:8001/services/adminApi/routes',
                      status=201)
        responses.add(
            responses.GET,
            'http://kong:8001/services/adminApi/routes/adminApiRegisterInstance',
            status=404)
        responses.add(
            responses.GET,
            'http://kong:8001/services/adminApi/routes/adminApiRenewInstance',
            status=404)
        responses.add(responses.POST,
                      'http://kong:8001/services/adminApi/routes',
                      status=201)
        responses.add(responses.GET,
                      'http://kong:8001/routes/adminApi/plugins',
                      status=200,
                      json={"data": []})
        responses.add(responses.POST,
                      'http://kong:8001/routes/adminApi/plugins',
                      status=201)
        responses.add(responses.GET,
                      'http://kong:8001/services/adminApi/plugins',
                      status=200,
                      json={"data": []})
        responses.add(responses.POST,
                      'http://kong:8001/services/adminApi/plugins',
                      status=201)
        responses.add(
            responses.GET,
            'http://kong:8001/routes/adminApiRegisterInstance/plugins',
            status=200,
            json={"data": []})
        responses.add(
            responses.POST,
            'http://kong:8001/routes/adminApiRegisterInstance/plugins',
            status=201)
        responses.add(responses.GET,
                      'http://kong:8001/routes/adminApiRenewInstance/plugins',
                      status=200,
                      json={"data": []})
        responses.add(responses.POST,
                      'http://kong:8001/routes/adminApiRenewInstance/plugins',
                      status=201)
        responses.add(responses.GET,
                      'http://kong:8001/plugins',
                      status=200,
                      json={"data": []})
        responses.add(responses.POST, 'http://kong:8001/plugins', status=201)
        self.subject.run()
        self.assertTrue(
            responses.assert_call_count(
                'http://kong:8001/routes/adminApi/plugins', 3))
        self.assertTrue(
            responses.assert_call_count(
                'http://kong:8001/routes/adminApiRegisterInstance/plugins', 2))
        self.assertTrue(
            responses.assert_call_count(
                'http://kong:8001/routes/adminApiRenewInstance/plugins', 4))
        self.assertTrue(
            responses.assert_call_count(
                'http://kong:8001/services/adminApi/plugins', 2))

    def test_get_admin_plugins(self):
        result = self.subject.get_admin_plugins()
        self.assertEqual(len(result), 8)

    @responses.activate
    def test_create_admin_service_and_failed(self):
        responses.add(responses.GET,
                      'http://kong:8001/services/adminApi',
                      status=404)
        responses.add(responses.POST, 'http://kong:8001/services', status=404)
        with self.assertRaises(SystemExit):
            self.subject.create_admin_service()
        self.assertEqual(
            responses.calls[1].request.body,
            'name=adminApi&protocol=http&port=8001&host=127.0.0.1')

    @responses.activate
    def test_create_admin_service_and_success(self):
        responses.add(responses.GET,
                      'http://kong:8001/services/adminApi',
                      status=404)
        responses.add(responses.POST, 'http://kong:8001/services', status=201)
        self.subject.create_admin_service()
        self.assertEqual(
            responses.calls[1].request.body,
            'name=adminApi&protocol=http&port=8001&host=127.0.0.1')
コード例 #42
0
class MyGraphicsView(QGraphicsView):
    signalZoomByMouse = pyqtSignal()

    def __init__(self, *args, **kwargs):
        super(MyGraphicsView, self).__init__()
        scene = QGraphicsScene(self)
        self.mainWindow = args[0]
        self.actFixture = Fixture(self)
        self.conf = loadconf()
        self.scene = scene
        scene.setItemIndexMethod(QGraphicsScene.NoIndex)
        scene.setSceneRect(0, 0, self.conf['x_max'], self.conf['y_max'])
        self.setScene(scene)
        self.setCacheMode(QGraphicsView.CacheBackground)
        self.setCacheMode(QGraphicsView.CacheNone)
        self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
        self.grabbed = None
        self.selected = None
        self.bgImage = None
        self.mainSprite = None
        self.zoom = 1
        self.zoomStep = 2  # used by menu commands
        self.zoomScale = 1  # used by mouse zoom
        self.signalZoomByMouse.connect(self.slotZoom, Qt.QueuedConnection)
        self.setTransformationAnchor(QGraphicsView.NoAnchor)

    def slotZoom(self):
        newMapped = QPointF(self.mapToScene(self.lastPos))
        deltaX = newMapped.x() - self.lastMapped.x()
        deltaY = newMapped.y() - self.lastMapped.y()
        self.translate(deltaX, deltaY)
        pass

    def wheelEvent(self, event):
        if event.modifiers() == Qt.ControlModifier:
            if event.orientation() == Qt.Vertical:
                self.lastPos = event.pos()
                self.lastMapped = QPointF(self.mapToScene(self.lastPos))

                if event.delta() > 0:
                    self.zoomScale *= 1.2
                    self.scale(1.2, 1.2)
                else:
                    self.zoomScale /= 1.2
                    self.scale(1 / 1.2, 1 / 1.2)

                self.signalZoomByMouse.emit()

        else:
            QGraphicsView.wheelEvent(self, event)

    def zoomIn(self):
        self.zoom *= self.zoomStep
        self.scale(self.zoomStep, self.zoomStep)

    def zoomOut(self):
        self.zoom *= 1.0 / self.zoomStep
        self.scale(1.0 / self.zoomStep, 1.0 / self.zoomStep)

    def drawBackground(self, painter, rect):
        painter.setBrush(QColor(255, 0, 0))
        painter.drawRect(0, 0, self.conf['x_max'], self.conf['y_max'])
        x0, y0 = self.center().x(), self.center().y()
        painter.drawLine(x0, 0, x0, self.conf['y_max'])
        painter.drawLine(0, y0, self.conf['x_max'], y0)

    def center(self):
        return QPoint(self.conf['x_max'] / 2, self.conf['y_max'] / 2)

    def loadSprite(self, filename):
        if self.mainSprite:
            self.scene.removeItem(self.mainSprite)
        pixmap = QPixmap.fromImage(QImage(filename))
        item = QGraphicsPixmapItem(pixmap)
        item.type = 'sprite'
        item.setOffset((self.conf['x_max'] - item.pixmap().width()) / 2,
                       (self.conf['y_max'] - item.pixmap().height()) / 2)
        item.setZValue(-0.1)
        self.mainSprite = item
        self.scene.addItem(item)

    def mousePressEvent(self, mouseEvent):
        if mouseEvent.button() == Qt.LeftButton:
            pos = QPointF(self.mapToScene(mouseEvent.pos()))
            items = self.scene.items(pos)
            if items and items[0].type == 'vertex':
                self.selected = items[0]
                self.grabbed = self.selected
            else:
                if self.mainSprite:
                    point = self.mapToScene(mouseEvent.pos())
                    x = point.x()
                    y = point.y()
                    self.actFixture.addVertex(x, y)
            self.mainWindow.updateText()

    def mouseMoveEvent(self, mouseEvent):
        if self.grabbed:
            point = self.mapToScene(mouseEvent.pos())
            x, y = point.x(), point.y()
            self.moveVertex(self.grabbed, x, y)

    def mouseReleaseEvent(self, mouseEvent):
        self.grabbed = None

    def setMainWindow(self, mainWindow):
        self.mainWindow = mainWindow

    def moveVertex(self, vertex, x, y):
        if isinstance(vertex, QGraphicsPixmapItem):
            x -= vertex.pixmap().width() / 2
            y -= vertex.pixmap().width() / 2
        if isinstance(vertex, QGraphicsRectItem):
            x -= vertex.rect().width() / 2
            y -= vertex.rect().width() / 2
        vertex.setX(x)
        vertex.setY(y)
        self.mainWindow.redrawFixtures()
        self.mainWindow.updateText()

    def moveVertexUp(self):
        if self.selected:
            x, y = self.getPos(self.selected)
            self.moveVertex(self.selected, x, y - 1)

    def moveVertexDown(self):
        if self.selected:
            x, y = self.getPos(self.selected)
            self.moveVertex(self.selected, x, y + 1)

    def moveVertexLeft(self):
        if self.selected:
            x, y = self.getPos(self.selected)
            self.moveVertex(self.selected, x - 1, y)

    def moveVertexRight(self):
        if self.selected:
            x, y = self.getPos(self.selected)
            self.moveVertex(self.selected, x + 1, y)

    def getPos(self, item):
        if isinstance(item, QGraphicsRectItem):
            x = item.x() + item.rect().width() / 2
            y = item.y() + item.rect().height() / 2
        if isinstance(item, QGraphicsPixmapItem):
            x = item.x() + item.pixmap().width() / 2
            y = item.y() + item.pixmap().height() / 2
        return x, y

    def removeSelectedVertex(self):
        if self.selected:
            self.removeVertex(self.selected)
            if self.actFixture.itemsSorted():
                self.selected = self.actFixture.itemsSorted()[-1]
            else:
                self.selected = None

    def removeVertex(self, vertex):
        self.actFixture.removeVertex(vertex)
        self.actFixture.redrawOutline()
        self.mainWindow.updateText()
コード例 #43
0
from fixture import Fixture

fixture = Fixture()
fixture.run()
コード例 #44
0
                  preferredday=row[4],
                  preferredtime=row[5],
                  weight=int(row[6])))
print(len(potential_matches))

print("Loading all available spots")
with open('resources/all_available_spots.csv',
          mode='r',
          newline='',
          encoding='utf-8') as csvfile:
    csvreader = csv.reader(csvfile, delimiter=',')
    for row in csvreader:
        fixtures.append(
            Fixture(round=row[0],
                    when=datetime.strptime(row[1] + " " + row[3],
                                           "%d/%m/%Y %H:%M"),
                    venue=row[4],
                    capacity=int(row[5])))
print(len(fixtures))

with open("resources/generated_fixtures.txt",
          mode='w',
          newline='',
          encoding='utf-8') as outfile:
    print(
        "Randomly assign a potential match to an available spot i.e. create a fixture"
    )
    for fixture in fixtures:  # Fill all available fixtures
        while fixture.available_capacity != 0:  # Fill all capacity for a given venue
            filtered_matches = list(
                filter(
コード例 #45
0
 def fixtures(self):
     if self._fixtures is None and self._data.get("fixtures", None):
         self._fixtures = [Fixture(fd) for fd in self._data["fixtures"]]
     else:
         self._fixtures = []
     return self._fixtures
コード例 #46
0
 def __init__(self, name, weight, position, battery_capacity):
     Fixture.__init__(self, name, weight, position)
     self._battery_capacity = battery_capacity
     self._battery_remaining = battery_capacity
コード例 #47
0
class UI:
	def __init__(self):
		DATA.Readini()
		self.ll = localLog.LocalLog()
		self.sfis = SFIS.SFIS()
		self.fix = Fixture()


		self.windowname = DATA.WindowName
		self.id = 0
		self.ISNid_list = []

	def drawframe(self):
		self.root = Tk(className = '\ACDC')
		self.root.geometry('800x550')

		self.drawlabel()
		self.drawcheckbox()
		self.drawbutton()

		self.edt_label1.focus_set()
		self.con_label7.set(DATA.OPID)
		self.con_label1.set('26EA01AC221803B6')
		self.con_label2.set('26EA01AC221800UL')
		self.con_label3.set('26EA01AC221803G3')
		# self.con_label6.set('26EA01AC221803B6')
		# self.con_label4.set('26EA01AC2118003M')
		# self.con_label5.set('26EA01AC22180192')

		for i in range(6):
			self.setresultlabel(i+1, ' Result ', 0)

		self.root.mainloop()

	def ret_btn(self, *argv):
		self.Start()

	def ret_lab1(self, *argv):
		val = self.edt_label1.get()

		if len(val) != 16:
			self.edt_label1.delete(0, END)

		if not self.ck2_con.get():
			self.edt_label2.focus_set()
		elif not self.ck3_con.get():
			self.edt_label3.focus_set()
		elif not self.ck4_con.get():
			self.edt_label4.focus_set()
		elif not self.ck5_con.get():
			self.edt_label5.focus_set()
		elif not self.ck6_con.get():
			self.edt_label6.focus_set()
		else:
			self.btn.focus_set()

	def ret_lab2(self, *argv):
		val = self.edt_label2.get()

		if len(val) != 16:
			self.edt_label2.delete(0, END)

		if not self.ck3_con.get():
			self.edt_label3.focus_set()
		elif not self.ck4_con.get():
			self.edt_label4.focus_set()
		elif not self.ck5_con.get():
			self.edt_label5.focus_set()
		elif not self.ck6_con.get():
			self.edt_label6.focus_set()
		else:
			self.btn.focus_set()

	def ret_lab3(self, *argv):
		val = self.edt_label3.get()

		if len(val) != 16:
			self.edt_label3.delete(0, END)

		if not self.ck4_con.get():
			self.edt_label4.focus_set()
		elif not self.ck5_con.get():
			self.edt_label5.focus_set()
		elif not self.ck6_con.get():
			self.edt_label6.focus_set()
		else:
			self.btn.focus_set()

	def ret_lab4(self, *argv):
		val = self.edt_label4.get()

		if len(val) != 16:
			self.edt_label4.delete(0, END)

		if not self.ck5_con.get():
			self.edt_label5.focus_set()
		elif not self.ck6_con.get():
			self.edt_label6.focus_set()
		else:
			self.btn.focus_set()

	def ret_lab5(self, *argv):
		val = self.edt_label5.get()

		if len(val) != 16:
			self.edt_label5.delete(0, END)

		if not self.ck6_con.get():
			self.edt_label6.focus_set()
		else:
			self.btn.focus_set()

	def ret_lab6(self, *argv):
		val = self.edt_label6.get()

		if len(val) != 16:
			self.edt_label6.delete(0, END)

		self.btn.focus_set()

	def drawcheckbox(self):
		self.ck1_con = IntVar()
		self.ck1 = Checkbutton(self.root, variable = self.ck1_con, font = ('arial', 30), command = self.click_1)
		self.ck1.grid(row = 1, column = 0)

		self.ck2_con = IntVar()
		self.ck2 = Checkbutton(self.root, variable = self.ck2_con, font = ('arial', 30), command = self.click_2)
		self.ck2.grid(row = 2, column = 0)

		self.ck3_con = IntVar()
		self.ck3 = Checkbutton(self.root, variable = self.ck3_con, font = ('arial', 30), command = self.click_3)
		self.ck3.grid(row = 3, column = 0)

		self.ck4_con = IntVar()
		self.ck4 = Checkbutton(self.root, variable = self.ck4_con, font = ('arial', 30), command = self.click_4)
		self.ck4.grid(row = 4, column = 0)

		self.ck5_con = IntVar()
		self.ck5 = Checkbutton(self.root, variable = self.ck5_con, font = ('arial', 30), command = self.click_5)
		self.ck5.grid(row = 5, column = 0)

		self.ck6_con = IntVar()
		self.ck6 = Checkbutton(self.root, variable = self.ck6_con, font = ('arial', 30), command = self.click_6)
		self.ck6.grid(row = 6, column = 0)

		self.ck7_con = IntVar()
		self.ck7 = Checkbutton(self.root, variable = self.ck7_con, font = ('arial', 30))
		self.ck7.grid(row = 1, column = 3)

		self.ck8_con = IntVar()
		self.ck8 = Checkbutton(self.root, variable = self.ck8_con, font = ('arial', 30))
		self.ck8.grid(row = 2, column = 3)

		self.ck9_con = IntVar()
		self.ck9 = Checkbutton(self.root, variable = self.ck9_con, font = ('arial', 30))
		self.ck9.grid(row = 3, column = 3)

		self.ck10_con = IntVar()
		self.ck10 = Checkbutton(self.root, variable = self.ck10_con, font = ('arial', 30))
		self.ck10.grid(row = 4, column = 3)

		self.ck11_con = IntVar()
		self.ck11 = Checkbutton(self.root, variable = self.ck11_con, font = ('arial', 30))
		self.ck11.grid(row = 5, column = 3)

		self.ck12_con = IntVar()
		self.ck12 = Checkbutton(self.root, variable = self.ck12_con, font = ('arial', 30))
		self.ck12.grid(row = 6, column = 3)

	def drawlabel(self):
		Label(self.root, font = ('arial', 15)).grid(row = 0, column = 0)
		Label(self.root).grid(row = 7, column = 0)

		self.label1 = Label(self.root, text = 'DUT1:', font = ('arial', 20))
		self.label1.grid(row = 1, column = 1)
		self.label2 = Label(self.root, text = 'DUT2:', font = ('arial', 20))
		self.label2.grid(row = 2, column = 1)
		self.label3 = Label(self.root, text = 'DUT3:', font = ('arial', 20))
		self.label3.grid(row = 3, column = 1)
		self.label4 = Label(self.root, text = 'DUT4:', font = ('arial', 20))
		self.label4.grid(row = 4, column = 1)
		self.label5 = Label(self.root, text = 'DUT5:', font = ('arial', 20))
		self.label5.grid(row = 5, column = 1)
		self.label6 = Label(self.root, text = 'DUT6:', font = ('arial', 20))
		self.label6.grid(row = 6, column = 1)


		self.con_label1 = StringVar()
		self.edt_label1 = Entry(self.root, textvariable = self.con_label1, font = ('arial', 25), borderwidth = 4)
		self.edt_label1.grid(row = 1, column = 2)
		self.edt_label1.bind('<Return>', self.ret_lab1)


		self.con_label2 = StringVar()
		self.edt_label2 = Entry(self.root, textvariable = self.con_label2, font = ('arial', 25), borderwidth = 4)
		self.edt_label2.grid(row = 2, column = 2)
		self.edt_label2.bind('<Return>', self.ret_lab2)

		self.con_label3 = StringVar()
		self.edt_label3 = Entry(self.root, textvariable = self.con_label3, font = ('arial', 25), borderwidth = 4)
		self.edt_label3.grid(row = 3, column = 2)
		self.edt_label3.bind('<Return>', self.ret_lab3)

		self.con_label4 = StringVar()
		self.edt_label4 = Entry(self.root, textvariable = self.con_label4, font = ('arial', 25), borderwidth = 4)
		self.edt_label4.grid(row = 4, column = 2)
		self.edt_label4.bind('<Return>', self.ret_lab4)

		self.con_label5 = StringVar()
		self.edt_label5 = Entry(self.root, textvariable = self.con_label5, font = ('arial', 25), borderwidth = 4)
		self.edt_label5.grid(row = 5, column = 2)
		self.edt_label5.bind('<Return>', self.ret_lab5)

		self.con_label6 = StringVar()
		self.edt_label6 = Entry(self.root, textvariable = self.con_label6, font = ('arial', 25), borderwidth = 4)
		self.edt_label6.grid(row = 6, column = 2)
		self.edt_label6.bind('<Return>', self.ret_lab6)

		self.rst_label1 = Label(self.root, font = ('arial', 32))
		self.rst_label1.grid(row = 1, column = 4)
		self.rst_label2 = Label(self.root, font = ('arial', 32))
		self.rst_label2.grid(row = 2, column = 4)
		self.rst_label3 = Label(self.root, font = ('arial', 32))
		self.rst_label3.grid(row = 3, column = 4)
		self.rst_label4 = Label(self.root, font = ('arial', 32))
		self.rst_label4.grid(row = 4, column = 4)
		self.rst_label5 = Label(self.root, font = ('arial', 32))
		self.rst_label5.grid(row = 5, column = 4)
		self.rst_label6 = Label(self.root, font = ('arial', 32))
		self.rst_label6.grid(row = 6, column = 4)



		self.ID_label = Label(self.root, text = 'OPID: ', font = ('arial', 14))
		self.ID_label.grid(row = 8, column = 1)

		self.con_label7 = StringVar()
		self.edt_label7 = Entry(self.root, textvariable = self.con_label7, font = ('arial', 14), width = 12)
		self.edt_label7.grid(row = 8, column = 2)

		self.Tms_label1 = Label(self.root, text = 'Times: ', font = ('arial', 14))
		self.Tms_label1.grid(row = 9, column = 1)
		self.Tms_label2 = Label(self.root, font = ('arial', 14))
		self.Tms_label2.grid(row = 9, column = 2)

		self.context_label = Label(self.root, font = ('arial', 15)) # times
		self.context_label.grid(row = 9, column = 2)

	def drawbutton(self):
		self.btn = Button(self.root, text = ' Start ', font = ('arial', 20), command = self.Start)
		self.btn.grid(row = 10, column = 4)
		self.btn.bind('<Return>', self.Start)

	def barcodeready(self):
		DATA.ISN = {}
		if not self.ck1_con.get():
			DATA.ISN[0] = self.con_label1.get().upper()
		else:
			DATA.ISN[0] = ''

		if not self.ck2_con.get():
			DATA.ISN[1] = self.con_label2.get().upper()
		else:
			DATA.ISN[1] = ''

		if not self.ck3_con.get():
			DATA.ISN[2] = self.con_label3.get().upper()
		else:
			DATA.ISN[2] = ''

		if not self.ck4_con.get():
			DATA.ISN[3] = self.con_label4.get().upper()
		else:
			DATA.ISN[3] = ''

		if not self.ck5_con.get():
			DATA.ISN[4] = self.con_label5.get().upper()
		else:
			DATA.ISN[4] = ''

		if not self.ck6_con.get():
			DATA.ISN[5] = self.con_label6.get().upper()
		else:
			DATA.ISN[5] = ''

		for key, value in DATA.ISN.items():
			if value:
				# self.ISNid_list.append(key)

				DATA.logfilepath = 'log' + str(key+1)
				with open(DATA.logfilepath, 'w') as fw:
					fw.write('START TEST: ')
					fw.write(value + '\n')

				DATA.csvfilepath = 'csv' + str(key+1)
				with open(DATA.csvfilepath, 'w') as fw:
					fw.write('')

	def clearbarcode(self):
		if not self.ck7_con.get():
			self.con_label1.set('')
		if not self.ck8_con.get():
			self.con_label2.set('')
		if not self.ck9_con.get():
			self.con_label3.set('')
		if not self.ck10_con.get():
			self.con_label4.set('')
		if not self.ck11_con.get():
			self.con_label5.set('')
		if not self.ck12_con.get():
			self.con_label6.set('')

	def setresultlabel(self, id, result, *argv):
		if id == 1:
			if not self.ck1_con.get():
				self.rst_label1['text'] = result
				if argv[0] == 1:
					self.rst_label1['bg'] = 'Red'
				elif argv[0] == 2:
					self.rst_label1['bg'] = 'MediumSpringGreen'
				elif argv[0] == 3:
					self.rst_label1['bg'] = 'MistyRose'
				else:
					self.rst_label1['bg'] = 'AliceBlue'

		if id == 2:
			if not self.ck2_con.get():
				self.rst_label2['text'] = result
				if argv[0] == 1:
					self.rst_label2['bg'] = 'red'
				elif argv[0] == 2:
					self.rst_label2['bg'] = 'MediumSpringGreen'
				elif argv[0] == 3:
					self.rst_label2['bg'] = 'MistyRose'
				else:
					self.rst_label2['bg'] = 'AliceBlue'

		if id == 3:
			if not self.ck3_con.get():
				self.rst_label3['text'] = result
				if argv[0] == 1:
					self.rst_label3['bg'] = 'red'
				elif argv[0] == 2:
					self.rst_label3['bg'] = 'MediumSpringGreen'
				elif argv[0] == 3:
					self.rst_label3['bg'] = 'MistyRose'
				else:
					self.rst_label3['bg'] = 'AliceBlue'

		if id == 4:
			if not self.ck4_con.get():
				self.rst_label4['text'] = result
				if argv[0] == 1:
					self.rst_label4['bg'] = 'red'
				elif argv[0] == 2:
					self.rst_label4['bg'] = 'MediumSpringGreen'
				elif argv[0] == 3:
					self.rst_label4['bg'] = 'MistyRose'
				else:
					self.rst_label4['bg'] = 'AliceBlue'

		if id == 5:
			if not self.ck5_con.get():
				self.rst_label5['text'] = result
				if argv[0] == 1:
					self.rst_label5['bg'] = 'red'
				elif argv[0] == 2:
					self.rst_label5['bg'] = 'MediumSpringGreen'
				elif argv[0] == 3:
					self.rst_label5['bg'] = 'MistyRose'
				else:
					self.rst_label5['bg'] = 'AliceBlue'

		if id == 6:
			if not self.ck6_con.get():
				self.rst_label6['text'] = result
				if argv[0] == 1:
					self.rst_label6['bg'] = 'red'
				elif argv[0] == 2:
					self.rst_label6['bg'] = 'MediumSpringGreen'
				elif argv[0] == 3:
					self.rst_label6['bg'] = 'MistyRose'
				else:
					self.rst_label6['bg'] = 'AliceBlue'



		self.edt_label1.focus_set()

	def Start(self, *argv):
		try:
			self.fix.connect()
			self.fix.fixturein()
		except  Exception as e:
			logE(Exception, e)

		threading.Thread(target = self.temp).start()


	def click_1(self):
		# self.flag_1 = not self.flag_1
		if self.ck1_con.get():
			self.label1['state'] = DISABLED
			self.edt_label1['state'] = DISABLED
		else:
			self.label1['state'] = NORMAL
			self.edt_label1['state'] = NORMAL

	def click_2(self):
		if self.ck2_con.get():
			self.label2['state'] = DISABLED
			self.edt_label2['state'] = DISABLED
		else:
			self.label2['state'] = NORMAL
			self.edt_label2['state'] = NORMAL

	def click_3(self):
		if self.ck3_con.get():
			self.label3['state'] = DISABLED
			self.edt_label3['state'] = DISABLED
		else:
			self.label3['state'] = NORMAL
			self.edt_label3['state'] = NORMAL

	def click_4(self):
		if self.ck4_con.get():
			self.label4['state'] = DISABLED
			self.edt_label4['state'] = DISABLED
		else:
			self.label4['state'] = NORMAL
			self.edt_label4['state'] = NORMAL

	def click_5(self):
		if self.ck5_con.get():
			self.label5['state'] = DISABLED
			self.edt_label5['state'] = DISABLED
		else:
			self.label5['state'] = NORMAL
			self.edt_label5['state'] = NORMAL

	def click_6(self):
		if self.ck6_con.get():
			self.label6['state'] = DISABLED
			self.edt_label6['state'] = DISABLED
		else:
			self.label6['state'] = NORMAL
			self.edt_label6['state'] = NORMAL

# find Dlg
	def temp(self):
		try:
			for i in range(int(DATA.AutoTest)):
				self.barcodeready()

				for ii in DATA.ISN:
					if DATA.ISN[ii]:
						self.setresultlabel(ii+1, ' Testing ', 3)
					else:
						self.setresultlabel(ii+1, ' Result ', 0)

				self.btn['state'] = 'disabled'
				self.context_label['text'] = i+1
				self.DeleteChromaTxt()
				self.searchwindow()
				# print(i + 1)
				time.sleep(5)
			self.fix.fixtureout()
		except  Exception as e:
			logE(Exception, e)
			logE('temp() fail')

	def DeleteChromaTxt(self):
		if os.path.exists(DATA.chromalogpath):
			os.remove(DATA.chromalogpath)
			print('Delete txt')

	def searchwindow(self):
		hld = win32gui.FindWindow(None, self.windowname)
		while hld == 0:
			time.sleep(1)
			hld = win32gui.FindWindow(None, self.windowname)
		print('find window')

		self.sendISNtowindow()
		for i in DATA.ISN:
			if DATA.ISN[i]:
				print('send %s success' % DATA.ISN[i])

		self.WaitChromaTxt()

	def sendISNtowindow(self):
		try:
			hld = win32gui.FindWindow(None, self.windowname)
			if hld > 0:
				btdlg = win32gui.FindWindowEx(hld, None, 'Button', None) # child
				# print('Button: %x' %btdlg)

				eddlg1 = win32gui.FindWindowEx(hld, None, 'Edit', None) # child
				# print('Edit: %x' %eddlg1)
				id = win32gui.GetDlgCtrlID(eddlg1)
				for i in range(6):
					if DATA.ISN[i]:
						win32api.SendMessage(win32gui.GetDlgItem(hld, id), win32con.WM_SETTEXT, 0, DATA.ISN[i])
					id += 1
			win32gui.SetForegroundWindow(btdlg)
			time.sleep(0.5)
			win32api.SendMessage(btdlg, win32con.WM_LBUTTONDOWN, 0, 0)
			time.sleep(0.5)
			win32api.SendMessage(btdlg, win32con.WM_LBUTTONUP, 0, 0)
		except Exception as e:
			logE(Exception, e)
			logE('sendISNtowindow fail')
			return

	def WaitChromaTxt(self):
		while not os.path.exists(DATA.chromalogpath): pass
		print('found txt')

		for i in DATA.ISN:
			if DATA.ISN[i]:
				self.firstfindISN = False
				self.final = True
				# self.flag = True
				self.result = False
				self.find = False
				self.items_content = []
				self.id = i + 1
				DATA.totalfails = 0
				DATA.test_failures = ''
				DATA.errorcode = ''
				DATA.currentpass = True
				DATA.full_info = []
				DATA.csv = []
				self.handleChromaTxt(self.id, DATA.ISN[i])
		self.clearbarcode()
		self.btn['state'] = 'normal'

	# def record(self, id, argv):
	# 	self.handleChromaTxt(id, argv)

	def handleChromaTxt(self, id, isn):
		firstfind = 0
		ISNlist = []
		time.sleep(1)

		try:
			with open(DATA.chromalogpath, 'r') as f:
				for line in f:
					if len(line.strip()):
						self.items_content.append(line.strip().split(';'))

			for items in self.items_content:
				if len(items) < 2:
					continue
				item = []
				for iii in range(len(items)):
					item.append(items[iii].strip())

				# print(items)
				if item and 'Serial_No' in item:
					serial_no = item[1]
					firstfind += 1

					if not serial_no in ISNlist:
						ISNlist.append(serial_no)

					if serial_no == isn and not self.firstfindISN:

						self.find = True
						self.firstfindISN = True
						DATA.logfilepath = 'log' + str(id)
						with open(DATA.logfilepath, 'a') as fw:
							fw.write('')
							# fw.write('START TEST: ')
							# fw.write(isn + '\n')

						DATA.csvfilepath = 'csv' + str(id)
						with open(DATA.csvfilepath, 'a') as fw:
							fw.write('')
						self.ll.basic(str(id))
						self.sfis.SFIS_LOGIN_DB()
						self.sfis.SFIS_CHECK_ROUTE(isn)
						self.sfis.BUILD_PHASE(isn)
						self.sfis.TEST_READ_FACTORY_CONFIG_MLB(isn)
					# else:
					# 	self.find = False
					# 	self.firstfindISN = False

				if firstfind != id:
					continue

				if item and 'TEST_' in item[0]:
					if item[1] == 'PASS':
						item[1] = '0'
					if item[1] == 'FAIL':
						item[1] = '1'

					if item[1] == '1':
						if (float(item[2]) > float(item[4])) and (float(item[2]) < float(item[3])):
							item[1] = '0'

					if self.firstfindISN:
						DATA.op(item[0] +','+ item[1] +','+ item[2] +','+ item[3] +','+item[4])

					if int(item[1]):
						DATA.totalfails += 1

						if len(DATA.test_failures):
							DATA.test_failures += ';'
						DATA.test_failures += item[0]

				if not self.firstfindISN:
					win32api.MessageBox(0, 'Not find ISN %s in file' %isn, 'Waring', win32con.MB_OK)
					logE('Not find ISN %s in file' %isn)
					return

			for key, value in DATA.ISN.items():
				if isn in ISNlist:
					self.sfis.SFIS_UPLOAD_TEST_RESULT(isn)
					self.sfis.SFIS_LOGIN_OUT()
					DATA.end(isn)
					break
				else:
					if value == isn:
						self.setresultlabel(key+1, '   FAIL  ', 1)
						return

			for key, value in DATA.ISN.items():
				if isn == value:
					if DATA.errorcode:
						self.setresultlabel(key+1, DATA.errorcode, 1)
					else:
						self.setresultlabel(key+1, '  PASS  ', 2)
		except Exception as e:
			logE(Exception, e)
			logE('handleChromaTxt fail')
コード例 #48
0
ファイル: test_merge.py プロジェクト: einmalfel/git-aflow
    def test_checks(self):
        Fixture.from_scheme('''1:
                               a:-a--a-
                               b:-b-''').actualize()

        # detached head
        misc.checkout('1/a^')
        self.assert_aflow_dies_with(
            'Error: detached head state. Please checkout some branch before '
            'proceed', 'merge', 'no_matter')

        # topic description applicable
        misc.checkout('1/a')
        self.assert_aflow_returns_0(None, 'finish')
        misc.checkout('1/b')
        self.assert_aflow_returns_0(None, 'finish')
        misc.checkout('1/staging')
        expected = 'If you are going to specify topic description and/or ' \
                   'type, you should merge one single topic'
        self.assert_aflow_dies_with(expected, 'merge', '-a', '-e', 'no matter')
        self.assert_aflow_dies_with(expected, 'merge', 'a', 'b', '-D')

        # working tree
        self.assert_aflow_returns_0(None, 'continue', 'a')
        os.remove('a')
        self.assert_aflow_dies_with(
            'Error: your working tree is dirty. Please, stash or reset your '
            'changes before proceeding.',
            'merge', 'no_matter')
        branch.reset('HEAD')

        # topic present in sources
        misc.checkout('master')
        self.assert_aflow_dies_with(
            'Using default topic source(s): staging' + os.linesep +
            'Merge failed. No topic a in sources 1/staging',
            'merge', 'a')
        self.assert_aflow_dies_with(
            'Merge failed. No topic a_v2 in sources 1/develop',
            'merge', '-s', 'develop', 'a_v2')

        # is there anything to merge
        self.assert_aflow_dies_with(
            'Using default topic source(s): staging' + os.linesep +
            'There is nothing to merge.',
            'merge', '-a')

        # dependency check
        self.assert_aflow_returns_0(None, 'start', 'c')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        self.assert_aflow_returns_0(None, 'finish')
        misc.checkout('1/staging')
        self.assert_aflow_dies_with(
            'Using default topic source(s): develop' + os.linesep +
            'Merge failed. Topic 1/c_v1 depends on 1/a_v1. Try merge it first '
            'or use "git af merge -d" to merge dependencies automatically',
            'merge', 'c')
        commit.merge('1/a_v2', "Merge branch '1/a_v2' into 1/staging")
        misc.checkout('master')
        self.assert_aflow_dies_with(
            'Using default topic source(s): staging' + os.linesep +
            'Merge failed. We should merge 1/a_v2 along with 1/a_v1, but '
            '1/a_v1 is absent in sources.',
            'merge', 'a')
        misc.checkout('1/staging')
        branch.reset('HEAD^')

        # source exists and belongs to ci
        self.assert_aflow_dies_with(
            'Cannot find branch 1/wrong_source or wrong_source.',
            'merge', '-a', '-s', 'wrong_source')
        misc.checkout('1/staging')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        misc.checkout('master')
        self.assert_aflow_returns_0(None, 'merge', 'a')
        self.assert_aflow_returns_0(None, 'rebase', '-n', '2')
        self.assert_aflow_returns_0(None, 'start', 'wrong_source')
        misc.checkout('1/staging')
        self.assert_aflow_dies_with(
            "Merge sources should belong to current iteration. 2/wrong_source"
            " doesn't.",
            'merge', '-a', '-s', '2/wrong_source')

        # consistency check
        branch.create('1/b_v2')
        misc.checkout('1/b_v2')
        commit.commit('no matter', allow_empty=True)
        misc.checkout('1/develop')
        commit.merge('1/b_v2')
        misc.checkout('1/staging')
        self.assert_aflow_dies_with(None, 'merge', 'no_matter')

        # merge into develop
        misc.checkout('1/develop')
        self.assert_aflow_dies_with(
            'You cannot merge into develop, use git af topic finish instead',
            'merge', 'a')

        # not valid aflow repo
        misc.checkout('1/staging')
        branch.delete('1/develop')
        self.assert_aflow_dies_with(
            'Error: could not get current iteration, we are probably not in '
            'git-aflow repo.',
            'merge', 'no_matter')
コード例 #49
0
ファイル: test_finish.py プロジェクト: einmalfel/git-aflow
    def test_checks(self):
        Fixture.from_scheme('''1:-b1
                               s:-b1
                               d:-b1
                               a:-a--1a
                               b:-1b
                               2:''').actualize()

        # no finish for develop, master and staging
        for branch_ in 'master', '1/develop', '1/staging':
            misc.checkout(branch_)
            self.assert_aflow_dies_with(
                'Finish failed for branch ' + branch_ + '. Cannot finish '
                'develop, master, staging or release/* branches.',
                'finish')

        # one topic is based on another
        branch.create('1/no_matter', '1/b')
        misc.checkout('1/no_matter')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_dies_with(
            'TB of current topic is based on another topic, which is illegal. '
            'You should either merge other topic instead of basing on it or '
            'name topic you are finishing appropriately.',
            'finish')
        misc.checkout('1/develop')
        branch.delete('1/no_matter')

        # unable to determine topic name
        misc.checkout('1/a^')
        self.assert_aflow_dies_with(
            'You are in detached head state now. Please check out topic you '
            'want to finish, e.g. "git af checkout topicA" or specify name '
            '(like git af topic finish -n TopicName if you are going to merge '
            'a commit, not branch',
            'finish')

        # name format
        misc.checkout('1/a')
        self.assert_aflow_dies_with(
            'Error: invalid topic name 1/\_v1. "..", "~", "^", ":", "?", "*", '
            '"[", "@", "", spaces and ASCII control characters are not allowed.'
            ' */release/*, */develop, */staging and master are not allowed too.'
            ' Input something like "fix_issue18" or "do_api_refactoring"',
            'finish', '-n', '\\')

        # may lose untracked files
        with open('b', 'w') as b:
            b.write('Does not matter')
        self.assert_aflow_dies_with(
            'Error: you have some untracked files which you may loose when '
            'switching to 1/develop. Please, delete or commit them. '
            'Here they are: b.',
            'finish')

        # conflict
        misc.add('b')
        commit.commit('no matter')
        self.assert_aflow_dies_with(
            'Finish failed because of conflicts between current topic and '
            '1/b_v1 in file b', 'finish')
        os.remove('b')
        branch.reset('HEAD^')

        # working tree
        os.remove('a')
        self.assert_aflow_dies_with(
            'Error: your working tree is dirty. Please, stash or reset your '
            'changes before proceeding.',
            'finish')
        branch.reset('HEAD')

        # use topic name corresponding to some other iteration
        self.assert_aflow_dies_with(
            'It is not possible to finish in current iteration topic from '
            'other one. Finish failed.',
            'finish', '-n', '2/a_v1')

        # topic based on current one exists
        self.assert_aflow_returns_0(None, 'finish')
        misc.checkout('1/a_v1^')
        self.assert_aflow_dies_with(
            'Finish failed. There is another topic (1/a_v1) in 1/develop which '
            'is based on one you are trying to finish.',
            'finish', '-n', 'no_matter')

        # already finished
        self.assert_aflow_returns_0(None, 'checkout', 'a')
        self.assert_aflow_dies_with(
            '1/develop already contains this revision of a',
            'finish')

        # dependency not merged
        branch.create('dependency', '1')
        misc.checkout('dependency')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_returns_0(None, 'continue', 'b')
        commit.merge('dependency')
        self.assert_aflow_dies_with(
            'Finish failed. Your topic depends on 1/dependency_v1 which is '
            'absent in 1/develop',
            'finish')

        # topic isn't based on its iteration
        branch.create('2/a')
        misc.checkout('2/a')
        self.assert_aflow_dies_with(
            'Finish failed. Current topic branch is not based on iteration '
            'start which is not allowed in git-aflow',
            'finish')

        # topic is based on later iteration
        branch.create('1/c', '2')
        misc.checkout('1/c')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_dies_with(
            'Current topic branch is based on 2. Use "git af topic port" to '
            'bring it to current iteration and then call '
            '"git af topic finish"',
            'finish')

        # not based on previous revision
        branch.create('1/a_v2', '1')
        misc.checkout('1/a_v2')
        commit.commit('no matter', allow_empty=True)
        self.assert_aflow_dies_with(
            'Cannot finish. There is elder revision of this topic in 1/develop '
            'and SHA you are trying to finish is not based on it. Please '
            'rebase your work on 1/a_v1',
            'finish')

        # empty topic
        self.assert_aflow_returns_0(None, 'start', 'No_matter')
        self.assert_aflow_dies_with(
            'Finish failed. Topic must contain at least one commit.',
            'finish')

        # there already is a later revision of this topic and it isn't based on
        # one being finished now
        misc.checkout('1/develop')
        backup_sha = commit.get_current_sha()
        commit.merge('1/a_v2')
        commit.revert('HEAD', 1, True)
        commit.commit(allow_empty=True)
        commit.revert('HEAD^^', 1, True)
        commit.commit(allow_empty=True)
        branch.delete('1/a_v2')
        self.assert_aflow_returns_0(None, 'checkout', 'a_v1')
        self.assert_aflow_dies_with(
            'Cannot finish. Newer revision 1/a_v2 was merged into 1/develop '
            'and it is not based on revision you are trying to finish.',
            'finish')
        misc.checkout('1/develop')
        branch.reset(backup_sha)

        # same revision in develop has different SHA
        commit.revert('HEAD', 1, True)
        commit.commit(allow_empty=True)
        self.assert_aflow_returns_0(None, 'checkout', 'No_matter')
        commit.commit('No matter', allow_empty=True)
        self.assert_aflow_dies_with(
            '1/a_v1 was already merged in 1/develop with different head SHA. '
            'Finish failed.',
            'finish', '-n', 'a_v1')
        branch.reset(backup_sha)

        # finish _vN while there is no _v(N-1)
        self.assert_aflow_returns_0(None, 'continue', 'a')
        commit.commit('no matter', True)
        self.assert_aflow_dies_with(
            'Wrong topic version specified. Latest revision has version == 1. '
            'Increment version by 1',
            'finish', '-n', 'a_v3')

        # finish _vN while there is no _v(N-1) in current iteration
        misc.checkout('2/develop')
        self.assert_aflow_returns_0(None, 'start', 'No_matter')
        commit.commit('no matter', True)
        self.assert_aflow_dies_with(
            'You should finish version 1 before finishing 2/a_v2',
            'finish', '-n', 'a_v2')